#include
#include
using namespace std;
class person{
private:
string name;
int age;
public:
person(string n,int a):name(n),age(a){}
void show(){
cout<<"My name is "<
}
/*
*sattic 属于类,但不是普通的类成员,所以访问方式有所区别
*/
static void fun(){
cout<<"I am static."<
}
void show1(){
cout<name<
}
void fun1(){
name="wo";
age=20;
cout<<(*this).name<<","<<(*this).age<
// return *this;
}
person& fun2(){
name="Jim";
age=9;
return *this;
}
};
int main()
{
person p("ygf",22);
person:: fun();
person *ptr=&p;
ptr->show();
p.show();
p.show1();
p.fun1();
// cout<<(fun2())->name<
}
阅读(659) | 评论(0) | 转发(0) |