自考新教材-p146_4(2)

阅读 165

2022-06-08

源程序:

#include <iostream>
using namespace std;

class CTest
{
private:
int n;
public:
CTest()
{
n = 1;
}
int GetValue() const
{
return n;
}
int GetValue()
{
return 2 * n;
}
};
int main()
{
const CTest objTest1;
CTest objTest2;
cout << objTest1.GetValue() << "," << objTest2.GetValue();
system("pause");
return 1;
}

运行结果:

自考新教材-p146_4(2)_#include

 


精彩评论(0)

0 0 举报