#include<iostream>
#include<string>
using namespace std;
class Person{
public:
Person(string name,int age){
this->name=name;
this->age=age;
}
void show(){
cout<<name<<" "<<age<<endl;
}
void operator()(){
cout<<"class the ()function"<<endl;
}
private:
string name;
int age;
};
int main(){
Person p("guangdong",22);
p.show();
p();
//p.operator()();
return 0;
}
#include<iostream>
#include<string>
using namespace std;
class Person{
public:
Person(int age){
this->age=age;
}
Person& operator++(){
++age;
return *this;
}
Person operator++(int){
int a=this->age;
Person pp(a);
++age;
return pp;
}
void show(){
cout<<age<<endl;
}
private:
int age;
};
int main(){
Person p(5);
p.show();
//++p;
//p.operator ++();
//p++;
//++p;
//Person pp=p++; //后置
Person pp=++p; //前置
pp.show();
return 0;
}