Quoted
int MyLayout::heightForWidth( int w ) const
{
if ( cache_dirty || cached_width != w ) {
// not all C++ compilers support "mutable"
MyLayout *that = (MyLayout*)this;
int h = calculateHeightForWidth( w );
that->cached_hfw = h;
return h;
}
return cached_hfw;
}
Quoted
int MyLayout::heightForWidth( int w ) const
{
if ( cache_dirty || cached_width != w ) {
// not all C++ compilers support "mutable"
cached_hfw = calculateHeightForWidth( w );
}
return cached_hfw;
}
Quoted
other question: What does "mutable" mean?
Quoted
Is the red part of First code nessary?
if yes, why? if not,What is the advantage?
This post has been edited 1 times, last edit by "dr_super" (Jun 7th 2004, 2:37am)
Quoted
Originally posted by dr_super
In the second code, can I get the HeightForWidth()? (I mean I store and return it)
Why is the HeightForWidth() cached in another object? (I mean if I want to return it , I must do that?)