Question from the C++ - Fundamentals test

What does the following code display? class A { public: void hello() {cout << "A" << endl;} }; class B : public A { public: void hello() {cout << "B" << endl;} }; void meet(A a1, A a2) { a1.hello(); a2.hello(); } int main() { B b; A a; meet(a, b); return 0; } Answer: "AA".

Medium

What does display the following code ?

class A {
public:
    void hello() {cout << "A" << endl;}
};

class B : public A {
public:
    void hello() {cout << "B" << endl;}
};

void meet(A a1, A a2) {
    a1.hello();
    a2.hello();
}

int main() {
    B b; 
    A a;
    meet(a, b);
    return 0;
}
Author: SamuelStatus: PublishedQuestion passed 16 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!