Home > DeveloperSection > Forums > How can specify a const member function?
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    June-15-2013 12:22 AM

 Visual C++ Visual C++ 
Ratings:


 1 Reply(s)
 832  View(s)
Rate this:
Hi Expert,

How can specify a const member function? 

Thanks. 


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-15-2013 4:37 AM

Hi,

Try this:

Class member functions can be declared as const.When this is done,that function cannot modify the object that invokes it.Also,a const object cannot invoke a non-const objects.However,a const member function can be called by either const or non-const objects.

example:

class{
int some_var;
public:
unt f1() const;
};

Don't want to miss updates? Please click the below button!

Follow MindStick