I have come across some C++ code.Why we have to use *this in block instead of this?
我有以下代码,我想知道为什么它使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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! } }; |