#include<iostream.h> #include<string.h> class student { public: int sid; char name[15]; int age; student() { this->sid = 1001; strcpy(this->name,"张三"); this->age = 20; } student(int sid,char *pname,int age) { this->sid = sid; strcpy(this->name,pname); this->age = age; } student(student& st) { this->sid = st.sid; strcpy(this->name,st.name); this->age = st.age; } ~student() { cout<<"开始析构一个对象!"<<endl; } /*void input() { cout<<"sid = "; cin>>sid; cout<<"name = "; cin>>name; cout<<"age = "; cin>>age; }*/ void output() { cout<<"sid = "<<sid<<endl; cout<<"name = "<<name<<endl; cout<<"age = "<<age<<endl; } }; void main() { student st1; student st2(1002,"历史",5000); student st3(st2); st1.output(); st2.output(); st3.output(); }