Я перехожу на свои старые экзамены, чтобы учиться на финал, и заметил некоторые вещи, которые я до сих пор не понимаю.Конструктор по умолчанию в производных классах
class Shape
{
private:
int center_x, int center_y;
public:
Shape (int x, int y) : center_x(x), center_y(y); {} //constructor initializer
}
class Rectangle : public Shape
{
private:
int length, width;
public:
Rectangle(): //this is where i have trouble, I am supposed to fill in missing code here
//but shape does not have a default constructor, what am i supposed to fill in here?
Rectangle (int x, int y, int l, int w) : Shape(x,y);{length = l; width = w;}
}
Благодаря
Можете уточнить свой вопрос a немного? –
Извините, я должен был добавить определения к указанным конструкторам, и когда они дали мне Rectangle():, я не знал, что заполнить после двоеточия. – ricefieldboy
Близко связанный: http://stackoverflow.com/q/1711990/179910 –