Ich habe eine Anwendung mit Basis-und abgeleiteten Klasse. Ich muss ein Feld der Basisklasse in abgeleitetem haben, aber habe einige Probleme, es zu initialisieren. Hier ist der Code:keine passende Funktion für den Aufruf von 'X :: X()'
#include <iostream>
using namespace std;
class X
{
public :
X(int x) { }
} ;
class Y : public X
{
X x ;
Y* y ;
Y(int a) : x(a) { }
} ;
int main()
{
return 0;
}
Und die Fehler:
/tmp/test.cpp||In constructor ‘Y::Y(int)’:|
/tmp/test.cpp|14|error: no matching function for call to ‘X::X()’|
/tmp/test.cpp|14|note: candidates are:|
/tmp/test.cpp|7|note: X::X(int)|
/tmp/test.cpp|7|note: candidate expects 1 argument, 0 provided|
/tmp/test.cpp|4|note: X::X(const X&)|
/tmp/test.cpp|4|note: candidate expects 1 argument, 0 provided|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|