[問題] 問一個有關prototype的問題QQ
下面一prototyp一部分的程式碼~
----
class Prototype
{
protected:
std::string type;
int value;
public:
virtual Prototype* clone() = 0;
std::string getType()
{
return type;
}
int getValue()
{
return value;
}
};
class ConcretePrototype1 : public Prototype
{
public:
ConcretePrototype1(int number)
{
type = "Type1";
value = number;
}
Prototype* clone()
{
return new ConcretePrototype1(*this);
}
};
----
我要問超白癡的問題QQ
為什麼ConcretePrototype1的建構子可以傳入*this
預設的建構子不是ConcretePrototype1()嗎~
麻煩大家幫我這個新手解答~謝謝QQ
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.25.236.5
→
01/25 21:40, , 1F
01/25 21:40, 1F
→
01/25 23:25, , 2F
01/25 23:25, 2F
→
01/26 01:32, , 3F
01/26 01:32, 3F
→
01/26 02:37, , 4F
01/26 02:37, 4F
→
01/26 02:38, , 5F
01/26 02:38, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章