C++类中指针成员怎么在构造函数初始化列表中初始化?

#include <iostream>
#include <dos.h>
using namespace std;
class Circle
{
public:
Circle():r(123){} //************************************************
void showR();
private:
const int *r;
};
void Circle::showR()
{
cout << *r << endl;
}

int _tmain(int argc, _TCHAR* argv[])
{
Circle Cir;
Cir.showR();
system("pause");
return 0;
}

上面的//******************* 这一句应当怎样写才合法?

第1个回答  2017-01-19
r(new int(123))本回答被提问者采纳
相似回答