/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/languages/C/Samples/virtual_func.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
 
 
3
class A
 
4
{
 
5
 public:
 
6
    void Caller();
 
7
    virtual void f();
 
8
};
 
9
 
 
10
void A::f()
 
11
{
 
12
    puts("Class A");
 
13
}
 
14
 
 
15
void A::Caller()
 
16
{
 
17
    f();
 
18
}
 
19
 
 
20
class B : public A
 
21
{
 
22
 public:
 
23
    void f();
 
24
};
 
25
 
 
26
void B::f()
 
27
{
 
28
    puts("Class B");
 
29
}
 
30
 
 
31
main()
 
32
{
 
33
    B *b=new B;
 
34
    b->Caller();
 
35
    ((A*)b)->Caller();
 
36
    b->A::Caller();
 
37
    ((A*)b)->A::Caller();
 
38
    delete b;
 
39
}
 
 
b'\\ No newline at end of file'