Created
August 24, 2015 11:18
-
-
Save BlockoS/b4414324212f9ef919c6 to your computer and use it in GitHub Desktop.
El crapo readonly attr
This file contains hidden or 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
#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