virtual functions

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
27
28
29
30
31
32
33

c l a s s S t o r a b l e {
p u b l i c :
v i r t u a l c o n s t c h a r * g e t _ f i l e () = 0 ;
v i r t u a l v o i d r e a d () = 0 ;
v i r t u a l v o i d w r i t e () = 0 ;
v i r t u a l ~S t o r a b l e () {w r i t e (); } // to be called from overriding destructors
};




c l a s s T r a n s m i t t e r : p u b l i c S t o r a b l e {
p u b l i c :
v o i d w r i t e ();
/ / ...
};
c l a s s R e c e i v e r : p u b l i c S t o r a b l e {
p u b l i c :
v o i d w r i t e ();
/ / ...
}; 




c l a s s R a d i o : p u b l i c T r a n s m i t t e r , p u b l i c R e c e i v e r {
p u b l i c :
c o n s t c h a r * g e t _ f i l e ();
v o i d r e a d ();
v o i d w r i t e ();
/ / ...
};


does write() act as a virtual function for radio fn too ???
Can you fix the spacing? And yes, writing virtual on one method makes it virtual for all the derived classes.
Topic archived. No new replies allowed.