next up previous
Next: Calling Fortran functions (including Up: C++/C Previous: Run-time calculations

Variable name precedence

Object member variables can be referred to from within the object as either: classname::varname or varname. However, if there is a local variable also named varname, this will take precedence over the object member and you'll have to be explicit about referring to classname::varname.
class myparm{ 
   int input1; int input2;  
myparm::myparm(int input1){ 
   myparm::input1=input1; // this is fine 
   input1=input1; // problem here; this will not assign the local input1 to the class member 
   input2=input1; // this is fine; the local input1 is assigned to the class member input2

Chris Paciorek 2012-01-21