Can someone explain why this is the answer?

This question is which function in main would result in a error. The answer is ptr->fun3() - can someone explain why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class A 
{ 
public : 
    void fun1(void); 
    virtual void fun2(void); 
};

class B: public A 
{ 
public : 
    virtual void fun2(void); 
    void fun3(void); 
};

int main() 
{ 
    A* ptr; 
    B   bobj; 
    B   cobj; 

    ptr = &bobj;

    .....        // <--- inserted at this line 

   return 0;
}
Because class A doesn't have any function called fun3.
Wow. I thought it had to with ptr being a pointer...sigh. thanks.
That's embarrassing.
Topic archived. No new replies allowed.