This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dummy { | |
private: | |
int X = 0; | |
const int Y = 1; | |
public: | |
//declares method const | |
int getY() const { return Y;} | |
//declares return type const | |
const int getX() { return X; } | |
//declares return type , method and pointer const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dummy { | |
private: | |
int X = 0; | |
public: | |
//this function will give an error if | |
//object declared is of constant type | |
int getX() { return X; } | |
//this function will work fine as | |
//we have declared it const. |