#include<iostream>
using namespace std;
class C
{
public:
int x;
C(int x)
{
this -> x = x;
}
int getX()
{
return x;
}
};
void main()
{
C c(5);
cout << c.getX();
system("pause");
}
#include<iostream>
using namespace std;
class C
{
public:
int x;
C(int x)
{
this -> x = x;
}
int getX() const
{
return x;
}
};
void main()
{
const C c(5);
cout << c.getX();
system("pause");
}
截图:
抱歉了老师,这周还没弄好时间。。。。。