Skip to content

Instantly share code, notes, and snippets.

@olafurw
Created July 3, 2016 21:26
Show Gist options
  • Save olafurw/693edb5aed460cd9468d52184a406d95 to your computer and use it in GitHub Desktop.
Save olafurw/693edb5aed460cd9468d52184a406d95 to your computer and use it in GitHub Desktop.
class Meow
{
public:
Meow();
int myWhateverValue;
const public: // const to the public, could also be "public const:" for parsing reasons
int myDelicateState;
};
Meow::Meow()
: myWhateverValue(42)
, myDelicateState(2)
{
}
int main()
{
Meow meow;
int whatever = meow.myWhateverValue; // ok
const int cWhatever = meow.myWhateverValue; // ok
const int cDelicate = meow.myDelicateState; // ok
int delicate = meow.myDelicateState; // error
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment