C++ multiple inheritances

Why is the answer 1 and not 2 to the following codes below? Revising for a test. Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Given the following code with multiple inheritances:
class A {
public: 
  void print(int a) { cout << "1"; };
};

clаss B {
public: 
  void print(float f) { cout << "2"; };
};

class AB : public A, public B { };

int main() {
  AB ab;
  ab.A::print(3.14f);
  return 0;
}
If this code is compilable, what is the output? Type NC if it is not compilable. 
1
ab.A::print(3.14f);

This line specifically states that the print function to be used is the one from class A.
Topic archived. No new replies allowed.