我有以下代码,我想知道为什么它使用*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!
}
};