-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathex15.24.25.cpp
33 lines (32 loc) · 1.42 KB
/
ex15.24.25.cpp
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
/***************************************************************************
* @file main.cpp
* @author Alan.W
* @date 24 Jan 2014
* @remark This code is for the exercises from C++ Primer 5th Edition
* @note
***************************************************************************/
//
// Exercise 15.24:
// What kinds of classes need a virtual destructor? What operations must a
// virtual destructor perform?
// Generally, a base class should define a virtual destructor.
// The destructor needs to be virtual to allow objects in the inheritance
// hierarchy to be dynamically allocated and destroyed.
//
// Exercise 15.25:
// Why did we define a default constructor for Disc_quote? What effect, if
// any, would removing that constructor have on the behavior of Bulk_quote?
//
// Without it, when building the statement below, the compiler would complain
// that:
//
// note: 'Bulk_quote::Bulk_quote()' is implicitly deleted because the default
// definition would be ill-formed.
//
// The reason is that a constructor taking 4 parameters has been defined, which
// prevented the compiler generate synthesized version default constructor. As a
// result, the default constructor of any class derived from it has been defined
// as deleted. Thus the default constructor must be defined explicitly so that
// the derived classes can call it when executing its default constructor.
//
int main(){ return 0; }