The first method of enumeration is not applicable in C++, and the second method defining commonality of the elements is used to declare and define a class in C++.
A class is not discerned or classified by its private or protected members, but by its public ones which are visible.
This basically restates the rules for member access (§15.3) [1]. We choose access for bases in the same way as for members. [1]
Question: When should a composition class or a derived class be used? Answer: Composition is used to describe the relationship that “A is part of B” while the single inheritance is used to represents the relationship that “A is a kind (or subset) of B” . And the multiple inheritances represent the relationship that “A is a kind of B in the same time A is a kind C” or “A is the intersection of set B and set C”.
By default, C++ matches a function call with the correct function definition at compile time. This is called static binding . You can specify that the compiler match a function call with the correct function definition at run time; this is called dynamic binding .
By default, C++ matches a function call with the correct function definition at compile time. This is called static binding . You can specify that the compiler match a function call with the correct function definition at run time; this is called dynamic binding .
Actually we can change Singleton a little bit to permit it to have some number of elements.
For example, we can think A0 represents flower , A1 represents rose , and A2 represents red rose .
For example, A_0 is integer , A1 is odd number , and A_2 is even numbe r. When A_1 has 2 more public functions compared to its base class A_0, then we can defined the below complete subclasses from A_0. class A_1: public A_0 { public: move(); draw(); }; class A_2: public A_0 { public: unmove(); draw(); }; class A_3: public A_0 { public: move(); undraw(); }; class A_4: public A_0 { public: unmove(); undraw(); };
A_0 can be an abstract class or not.
Actually we can pick up the two arbitrary classes and then derive a new class from them in C++, however we need to think of the semantics of what we are doing. For example, 1) the class of TCP process can be derived from the two classes: Process and TCP ; 2) some guy is a scientist and musician . class C: public A, protected B { … }; Only the friends of B, the derived classes of B and the friends of the derived classes of B think C is a kind of A and B. class C: public A, private B { … }; Only the friends of B think C is a kind of A and B.
From above figure, we can understand why class window is declared as the virtual base of class window_with_menu and class window_with_border.