Onkel Schuppig
Erfahrenes Mitglied
Hallo zusammen,
unten stehender Code soll folgendes ausgeben:
A = 1, B = 2
Kann mir evtl. jemand das Brett vom Kopf entfernen?
Grüße Onkel Schuppig
unten stehender Code soll folgendes ausgeben:
A = 1, B = 2
Kann mir evtl. jemand das Brett vom Kopf entfernen?

Grüße Onkel Schuppig
Code:
struct A {
A(int a0) : a(a0) { }
int a;
friend ostream& operator<<(ostream& os, A& c) { os << "A = " << c.a; return os; }
};
struct B : A {
B() : A(1), b(2) { }
int b;
// in der nächsten Zeile ist irgendetwas falsch:
friend ostream& operator<<(ostream& os, B& c) { os << A << ", B = " << c.b; return os; }
};
B test;
cout << test << endl;