#include <iostream>
using namespace std;
class Point
{
private: //私有 但在类里边共有,类外私有
int x;
int y;
public: //共有
void show()
{
cout<<x<<endl;
cout<<y<<endl;
}
void setPoint(int a, int b)
{
x=a;
y=b;
}
};
int main ()
{
Point p;
p.setPoint(3,4);
p.show();
return 0;
}
<span style="color:#ff6666;">/*class point
{
public:
int x;
int y;
};
int main()
{
point p;
p.x=3;p.y=4;
cout<<p.x<<p.y<<endl;
return 0;
}*/ //基础版本</span>
class 2.0 私有共有
最新推荐文章于 2023-03-02 14:14:18 发布