2 Non-polymorphic classes

A non-polymorphic (static) class is one that has no virtual methods, inherited or otherwise. We can illustrate this with the following example:


Listing 1:Staticinheritance.
 
1class A 
2{ 
3  public
4    int i; 
5    void m1(void); 
6}
7 
8class B : public A 
9{ 
10  public
11    int j; 
12    void m1(void); 
13    void m2(void); 
14}
15 
16void test(void
17{ 
18  A myA; 
19  B myB; 
20 
21  myA.m1(); 
22  myB.m1(); 
23  myB.m2(); 
24  (static_cast<*>(&myB))>m1();  
25}

How are the method invocations implemented in the test subroutine?

 2.1 Equivalent C code
 2.2 Bottom line