- 329 名前:名前は開発中のものです。 [02/01/13 18:11 ID:xI5bVNxm]
- ま、こういうことが論理的に可能ですな。実際にはやらないけど。
#include <iostream> using namespace std; class Test { private: int n; public: Test(){ n = 0; } const int& getN() const { return n; } }; int main() { Test test; const_cast<int&>(test.getN()) = 5; cout << test.getN() << endl; return 0; }
|

|