HOW CAN SPECIFY A CONST MEMBER FUNCTION?

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
 1126  View(s)
Ratings:
Rate this:
Hi Expert,

How can specify a const member function? 

Thanks. 
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: How can specify a const member function?

    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;
    };

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!