5 Method overriding

Method overriding is the same as usual, as the overriding definition in the subclass hides the access to the overriden methods from its superclasses. Listing 4 illustrates this:


Listing 4:overridemethod
 
1class A 
2{ 
3  public
4    void m1(void{} 
5}
6 
7class B 
8{ 
9  public
10    void m1(void{} 
11}
12 
13class C : public A, public B 
14{ 
15  public
16    void m1(void{ A::m1(); B::m1(); } 
17}
18 
19void test(void
20{ 
21  C myC; 
22 
23  myC.m1();  
24}

Note that in this case, the overriding definition refers to the overriden methods inherited from both superclasses.