Skip to content

Instantly share code, notes, and snippets.

@BlockoS
Created August 24, 2015 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlockoS/b4414324212f9ef919c6 to your computer and use it in GitHub Desktop.
Save BlockoS/b4414324212f9ef919c6 to your computer and use it in GitHub Desktop.
El crapo readonly attr
#include <iostream>
class A
{
public:
A() : u(this->_v), _v(1) {}
~A() {}
public:
const int& u;
private:
int _v;
};
int main()
{
A b;
std::cout << b.u << std::endl;
b.u++; // error!
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment