源程序:
#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;
}
const常量用初始化列表初始化
阅读 158
2022-06-08
源程序:
#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)