所以,我的问题是我对课程知之甚少。所以,我试图让这个构造函数工作。我需要基构造函数和派生类的构造函数来工作,而无需在那里实现它。我可以在那里定义它,但我无法实现它。编译器告诉我它需要一个花括号。#ifdef SHAPE.H #endif SHAPE.H #define
#include<string>
using namespace std;
class QuizShape
{
private:
char outer, inner;
string quizLabel;
public:
//Constructor
QuizShape();
};
class Rectangle : public QuizShape
{
public:
int height, width;
//Getter & setter methods
int getHeight() const;
void setHeight(int);
int getWidth() const;
void setWidth(int);
//Constructor for Rectangle
Rectangle() : QuizShape();
};
class Square : public Rectangle
{
public:
//constructors
Square() : Rectangle (); This area here is where the error comes // IT says it expects a { but I'm not allowed to define the constructor in line.
Square(int w, int h) : Rectangle (height , width);
};
class doubleSquare : public Square
{
//Fill in with constructors
};
我不明白它给我的错误。我很确定我也没有重新定义它。