c++におけるクラスの構造と構造とコピー構造関数

756 ワード

#include 
#include 
#include 
#include 
using namespace std;

class student {
public:
	student() {//      
		cout << "      " << endl;
	}
	~student() {//    
		cout << "    " << endl;
	}
	student(int x) {//         
		a = x;
		cout << "a=" << a << endl;
	}
	student(student& s) {//      
		this->a = s.a;
		cout << "      " << endl;
	}
private:
	int a;
};



int main()
{
	student* stu = new student;//      ;
	student* stu2 = new student(4);//    ;
	student stu4;
	student stu3(stu4);//      ;
	delete stu;
	stu = NULL;
	delete stu2;
	stu2 = NULL;
	return 0;
}