Я написал этот код, но он не мог скомпилироваться, и я получил эту ошибку в Clang ++ v18.1.3 < /p>
constructor for 'C' must explicitly initialize the base class 'A' which does not have a default constructor
< /code>
class A
{
public:
explicit A(int n)
{}
};
class B : virtual public A
{
public:
B(int n)
: A(n)
{}
};
class C : public B
{
public:
C(int n)
: B(n)
{}
};
< /code>
i could call constructor of A inside constructor of C and it resolve the problem but i do not have any idea why this problem happened and i want to know is there any official way to solve this problem?
Подробнее здесь: https://stackoverflow.com/questions/794 ... h-does-not
Конструктор для «C» должен явно инициализировать базовый класс «A», который не имеет конструктора по умолчанию ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Могу ли я унаследовать от класса, если базовый класс не имеет конструктора
Anonymous » » в форуме C# - 0 Ответы
- 5 Просмотры
-
Последнее сообщение Anonymous
-