![](/img/trans.png)
[英]Can we have any other way to access c++ code in Android instead using JNI
[英]I have come across some C++ code.Why we have to use *this in block instead of this?
我有以下代码,我想知道为什么它使用*this
代替this
。
class Quotation
{
protected:
int value;
char* type;
public:
virtual Quotation* clone()=0;
char * getType()
{
return type;
}
int getValue()
{
return value;
}
};
class bikeQuotation : public Quotation
{
public:
bikeQuotation(int number)
{
value=number;
type="BIKE";
}
Quotation * clone()
{
return new bikeQuotation(*this); // <-- Here!
}
};
this
是指向对象的指针 。 复制构造函数需要对该对象的引用 。 将指针转换为引用的方式是使用解引用*
运算符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.