Declaring object as const

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
There is a class.

class MyClass{
int value;
public:
MyClass(int v=0) {value = v;}
int getValue() const {return value;}
};


We can declare object as const(or non-const) like following.

const MyClass myclass(20);

The result is the same when declare object as const or non-const.

What does the const mean when it is used in declaring object as const?

Continue reading...
 
Back
Top