我有一些C ++代码,我一直认为声明被错误地终止了。我检查了所有的陈述,但看不到我错过分号的地方。我已经查看了我的计划十亿次但却找不到异常。这是代码。
class PizzaFactory
{
public:
virtual Pizza* bake() = 0;
};
class CheeseFactory : public PizzaFactory
{
private:
public:
Pizza* bake() override //Declaration terminated incorrectly
{
Dough doe, *newDoe = &doe;
TomatoSauce ts, *newTS = &ts;
Cheese chz, *newChz = &chz;
Pizza myPizza(MAX_TOPS);
Pizza* newPizza = &myPizza;
newPizza.add(newDoe);
newPizza.add(newTS);
newPizza.add(newChz);
return newPizza;
}
}; //here is where the "Unexpected '}'" is thrown and declaration
//terminated
//incorrectly
该行" Pizza * bake()覆盖"给出了错误。它也会抛出相同的错误并且"意外的'}'"在最后一行代码中。我不明白。