File: implementing.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (21 lines) | stat: -rw-r--r-- 1,273 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Pure virtual member functions may be implemented. To implement a pure virtual
    hi(member function: pure virtual implementation)
    hi(pure virtual member: implementation)
 member function, provide it with its normal tt(= 0;) specification, but
implement it as well. Since the tt(= 0;) ends in a semicolon, the pure virtual
member is always at most a declaration in its class, but an implementation may
either be provided outside from its interface (maybe using tt(inline)).

    Pure virtual member functions may be called from derived class objects or
from its class or derived class members by specifying the base class and scope
resolution operator together with the member to be called. Example:

        verbinclude(-a examples/purevirtualimp.cc)

    Implementing a pure virtual member has limited use. One could argue that
the pure virtual member function's implementation may be used to perform tasks
that can already be performed at the base class level. However, there is no
guarantee that the base class virtual member function is actually going to be
called.  Therefore base class specific tasks could as well be offered by a
separate member, without blurring the distinction between a member doing some
work and a pure virtual member enforcing a protocol.