T
Trevor M. Lango
For the sake of discussion, consider a private member variable within a
class as follows:
int someVar;
Now consider two public member function as follows:
void setSomeVar( const int = 0 );
int getSomeVar( ) const;
Is it possible to have the setSomeVar member function's default argument
be the current value of someVar rather than some arbitrary number (zero
in this example)? So basically if setSomeVar is called without
arguments, it leaves the value of someVar unchanged?
I tried both the following (which don't work):
void setSomeVar( const int = someVar );
void setSomeVar( const int = getSomeVar( ) );
Any ideas on how to either fix one (or both) of these, or an entirely
different approach...?
Any suggestions appreciated!
class as follows:
int someVar;
Now consider two public member function as follows:
void setSomeVar( const int = 0 );
int getSomeVar( ) const;
Is it possible to have the setSomeVar member function's default argument
be the current value of someVar rather than some arbitrary number (zero
in this example)? So basically if setSomeVar is called without
arguments, it leaves the value of someVar unchanged?
I tried both the following (which don't work):
void setSomeVar( const int = someVar );
void setSomeVar( const int = getSomeVar( ) );
Any ideas on how to either fix one (or both) of these, or an entirely
different approach...?
Any suggestions appreciated!