33,311
社区成员
发帖
与我相关
我的任务
分享
const A & A::GetHigher( const A & a ) const
{
if ( m_nHeight < a.m_nHeight )
{
return a;
}
else
{
return *this; // 如果没有this,这里玩不转了。
}
}
#include <iostream>
using namespace std;
class A
{
public:
int b;
static A* pointer;
A(int i):b(i){};
void ToThis()
{
pointer = this; //使得pointer指向类的本身。。。
}
};
A* A::pointer = new A(6);
int main()
{
A temp = A(8);
temp.ToThis();
cout<<A::pointer->b;
return 0;
}
#include <iostream.h>
#include <stdlib.h>
class ca
{
int a;
public:
ca(int a)
{
this->a=a;//这里this->a就可以引用到对象里面的那个a
}
};
void main()
{
ca a(1);
}