#include <iostream>
using namespace std;
class T1
{
const int t = 100;
public:
T1()
{
cout << "T1 constructor: " << t << endl;
}
};
const メンバー変数tを 100 で初期化しようとすると、次のエラーが表示されます。
test.cpp:21: error: ISO C++ forbids initialization of member ‘t’
test.cpp:21: error: making ‘t’ static
値を初期化するにはどうすればよいconstですか?