0
点赞
收藏
分享

微信扫一扫

const常量用初始化列表初始化

源程序:

#include <iostream>
#include <cmath>
using namespace std;

class A
{
private:
const int a;
public:
A(int x)
{
a=x;
}

void show()
{
cout<<"a="<<a<<endl;
}
};

int main()
{
A m(5);
m.show();
return 1;
}


举报

相关推荐

0 条评论