0からC++(七)構造体とクラスを学ぶ

1258 ワード

詳細

#include ;
using namespace std;

//   .            public
struct People
{
	int a;
	int b;
	void output()
	{
		a = 1000;
		b = 2000;
		cout << a << endl << b << endl;
	}
};

// .                private。
class Point
{
public :
	int x;
	int y;

	//      
	Point()
	{
		x = 1;
		y = 2;
	}
	//          
	Point(int a,int b)
	{
		x = a;
		y = b;
	}
	//    。           。
	~Point()
	{
		cout << "~Point()" << endl;
	}
	
	void output()
	{
		cout << x << endl << y << endl;
	}
	void output(int x,int y)
	{
		this->x = x;
		this->y = y;
	}
};


  
  
  
int main(){ 

   People mPeople;
   mPeople.output();
	
   //        p1
   Point p1; 
   p1.output();

   //        p2    。
   Point p2(8,8);
   p2.output(80,80);
   p2.output();


  

	return 0 ;
}