this的使用
#include"iostream"using namespace std;
class myclass
{
public :
myclass(int a,int b,int c);
static void getsum();
private:
int a,b,c;
static int sum;
};
int myclass::sum=0;
myclass::myclass(int a,int b,int c)
{
this->a=a;
this->b=b;
this->c=c;
sum+=a+b+c;
}
void myclass ::getsum()
{
//cout<<a<<endl;//
cout<<"sum="<<sum<<endl;
}
void main()
{
myclass m(1,2,3);
m.getsum();
myclass n(4,5,6);
n.getsum();
myclass::getsum();
}
this->a=a;
this->b=b;
this->c=c;这三句是什么意思啊