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;
}

原文地址:https://www.cnblogs.com/duanqibo/p/15590170.html