重庆网站设计平台,怎么样让网站宣传自己,网站建设要后台吗,php商场网站开发经验定义一个Person类#xff0c;私有成员int age#xff0c;string name#xff0c;定义一个Stu类#xff0c;包含私有成员double *score#xff0c;写出两个类的构造函数、析构函数、拷贝构造和拷贝赋值函数#xff0c;完成对Person的运算符重载(算术运算符、条件运算…定义一个Person类私有成员int agestring name定义一个Stu类包含私有成员double *score写出两个类的构造函数、析构函数、拷贝构造和拷贝赋值函数完成对Person的运算符重载(算术运算符、条件运算符、逻辑运算符、自增自减运算符、插入/提取运算符)
#include iostreamusing namespace std;class person
{int age;string name;
public:person(string a):age(18),name(a){}person(int a,string b):age(a),name(b){}~person(){}person(const person other):age(other.age),name(other.name){}person operator(const personother){this-ageother.age;this-nameother.name;return *this;}void show(){coutage:ageendlname:nameendl;}person operator(const personother){int agethis-ageother.age;static string name;name this-nameother.name;return person(age,name);}bool operator(person other){if((this-ageother.age)(this-nameother.name))return true;elsereturn false;}bool operator(person other){if(this-ageother.age)return true;elsereturn false;}bool operator(person other){return (this-ageother.age)||(this-nameother.name);}int getage(){return age;}friend ostream operator(ostream out,personc1);friend istream operator(istream in,person c1);
};
ostream operator(ostream out,personc1)
{outage:c1.ageendlname:c1.nameendl;return out;
}
istream operator(istream in,person c1)
{inc1.agec1.name;return in;
}
class stu
{double *score;person p1;
public:stu(string a):score(new double(12.5)),p1(a){}stu(double a,string b):score(new double(a)),p1(b){}~stu(){delete score;}stu(const stuother):score(new double(*(other.score))),p1(other.p1){}stu operator(const stuother){*(this-score)*(other.score);this-p1other.p1;return *this;}void show(){coutscore:*scoreendl;p1.show();}
};
int main()
{string azhangsan;string blisi;string cwangwu;stu a1(a);a1.show();coutendl;person p1(a);coutp1endl;person p2(b);coutp2endl;person p3(c);coutp3endl;person p4(p1p2);p4.show();coutendl;cout(p1p2)endl;cout(p1p2)endl;cout(p1p2)endl;return 0;
}