Skip to content

Commit ee5379e

Browse files
committed
added review03-24 for chapter12
1 parent 8fe3cbe commit ee5379e

File tree

23 files changed

+161
-0
lines changed

23 files changed

+161
-0
lines changed

Chapter12/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,70 @@ What is an application domain?
3232

3333
## [Review 2](review/02.txt)
3434
What are ideals for naming?
35+
36+
## [Review 3](review/03.txt)
37+
What can we name?
38+
39+
## [Review 4](review/04.txt)
40+
What services does a `Shape` offer?
41+
42+
## [Review 5](review/05.txt)
43+
How does an abstract class differ from a class that is not abstract?
44+
45+
## [Review 6](review/06.txt)
46+
How can you make a class abstract?
47+
48+
## [Review 7](review/07.txt)
49+
What is controlled by access control?
50+
51+
## [Review 8](review/08.txt)
52+
What good can it do to make a data member `private`?
53+
54+
## [Review 9](review/09.txt)
55+
What is a virtual function and how does it differ from a non-virtual function?
56+
57+
## [Review 10](review/10.txt)
58+
What is a base class?
59+
60+
## [Review 11](review/11.txt)
61+
What makes a class derived?
62+
63+
## [Review 12](review/12.txt)
64+
What do we mean by object layout?
65+
66+
## [Review 13](review/13.txt)
67+
What can you do to make a class easier to test?
68+
69+
## [Review 14](review/14.txt)
70+
What is an inheritance diagram?
71+
72+
## [Review 15](review/15.txt)
73+
What is the difference between a `protected` member and a `private` one?
74+
75+
## [Review 16](review/16.txt)
76+
What members of a class can be accessed from a class derived from it?
77+
78+
## [Review 17](review/17.txt)
79+
How does a pure virtual function differ from other virtual functions?
80+
81+
## [Review 18](review/18.txt)
82+
Why would you make a member function virtual?
83+
84+
## [Review 19](review/19.txt)
85+
Why would you not make a member function virtual?
86+
87+
## [Review 20](review/20.txt)
88+
Why would you make a virtual member pure?
89+
90+
## [Review 21](review/21.txt)
91+
What does overriding mean?
92+
93+
## [Review 22](review/22.txt)
94+
Why should you always suppress copy operations for a class in a class hierarchy?
95+
96+
## [Review 23](review/23.txt)
97+
How does interface inheritance differ from implementation inheritance?
98+
99+
## [Review 24](review/24.txt)
100+
What is object-oriented programming?
101+

Chapter12/review/03.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
We can name member functions, data members of our classes and our types.
2+
It is important to give meaningful names for public members of our types.

Chapter12/review/04.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Shape is an abstract class that provides the general interface of a graphical object,
2+
along with the common implementation for visible objects, such as color, line style, etc.
3+
- It ties our graphical objects to a Window.
4+
- It deals with color and style for our lines and fills.
5+
- It holds a sequence of points but leaves it up to our classes to interpret them.
6+
- It provides a draw_specifics() function that derived classes must define (since it is a pure virtual function).

Chapter12/review/05.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
An abstract class differs from a concrete (non-abstract) class
2+
in that it is impossible to create an object of an abstract type.
3+
An abstract class can only be used as a base class.

Chapter12/review/06.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
We can make abstract classes by declaring a pure virtual function
2+
or by making its constructors protected so as to only allow
3+
derived classes to call it.

Chapter12/review/07.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Access control dictates who has access to class members:
2+
There are three access groups:
3+
- Public:
4+
accessible by:
5+
- own members
6+
- derived class' members
7+
- other code
8+
- Protected:
9+
accessible by:
10+
- own members
11+
- derived class' members
12+
- Private:
13+
accessible by:
14+
- own members

Chapter12/review/08.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
By making a data member private, we make sure that the state of the object
2+
is valid, since users can only use the public interface to change its values,
3+
which manages the invariant.
4+
Also we prevent user code from breaking by accessing members through a well-defined
5+
interface, not directly, when making changes to our classes by encapsulating the representation.

Chapter12/review/09.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
A virtual function is a member function whose definition can be overridden by derived classes.
2+
Virtual functions are looked up at run-time, when calling the base class' function by the same name,
3+
the derived class' function will be called based on its dynamic type.
4+
Non-virtual functions on the other hand are called at compile-time, based on the static type of the object.
5+
Classes with virtual functions have an additional, hidden member, a vptr, that points to a vtable,
6+
a container that keeps track of the available virtual functions' definitions for the current type.

Chapter12/review/10.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A base class is a class that a derived class inherits its members from through inheritance.
2+
A base class is also called a superclass, a derived class is also called a subclass.

Chapter12/review/11.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Specifying the base class to inherit from through inheritance makes a class derived from its base.
2+
The derived class gets all of the members of its base.

0 commit comments

Comments
 (0)