Код: Выделить всё
error: constructor for 'Banana' must explicitly initialize the member 'f' which does not have a default constructorstruct Apple {
int x;
Apple(const int x);
};
Apple::Apple(const int x) {
this->x = x;
}
struct Fuji : public Apple {
int y;
Fuji(const int x, const int y);
void get_banana();
};
Fuji::Fuji(const int x, const int y) : Apple(x) {
this->y = y;
}
struct Banana {
int z;
Fuji f;
Banana(const int z, Fuji f);
};
Banana::Banana(const int z, Fuji f) {
this->z = z;
this->f = f;
}
void Fuji::get_banana() {
auto banana = Banana(7, *this);
}
< /code>
Любое понимание будет высоко оценено. Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/794 ... using-this
Мобильная версия