class myclass {
public:
myclass(string name = "", int age = 0) :name(name), age(age) {}
void print()
{
cout << name << ":" << age << endl;
}
friend myclass operator+(myclass object1, myclass object2);
//类的成员函数重载
myclass operator-(myclass object1)
{
return myclass(this->name, age - object1.age);;
}
friend std::ostream& operator<<(std::ostream& stream, const myclass& other);
friend std::istream& operator>>(std::istream& istream, myclass& thiso);
private:
string name;
int age;
};