Examples of using Derived class in English and their translations into Russian
{-}
-
Official
-
Colloquial
A virtual function may be overridden in a derived class.
The syntax for creating a derived class from an already existing on is as follows.
It serves to consolidate the theoretical foundations, derived classes.
Casting pointers from the derived class to the base class is a typical situation.
The private class members of the base class are not available for the derived class.
In the following example, the Derived class inherits from the Base class. .
The derived class uses the members of the base class, but can also modify and supplement them.
The public inheritance also means that derived classes(CCircle and CSquare) are CShapes.
Access to the members of the basis class can be redefined during inheritance in derived classes.
An object of the base class is first cast to a derived class by using the'dynamic_cast' operator.
The derived class may include the implementation of member functions, different from the base class. .
However, analyzer would not show V717 warning in case when there are no new non-static members in the derived class.
Therefore, derived classes, inherited from the base class CShape will be declared as follows.
You can use the explicit casting to convert the base class pointers to the pointers of a derived class.
It is most likely the object of the derived class that the programmer intended to check for nullptr before using it.
Derived class constructors will execute after all delegation in their base classes is complete.
The types involved can be integer, enumerations, or pointers orreferences to the base and derived classes.
Further, for each derived class, this function is implemented in accordance with characteristics of a descendant class. .
For example, the following code presents two classes, the base class Rectangle, and the derived class Box.
The derived class inherits the description of the base class, thus any re-development and re-testing of code is unnecessary.
In protected inheritance, public andprotected members of base class become protected members of derived class.
A typical case is when a base class contains a virtual function, and derived classes have their own versions of this function.
The pointer to the base class can indicate either a base class object or the object of a derived class.
The derived class is a modification of the base class, it inherits the protected and public members of the base class. .
Depending on the class, to which the created object belongs,it calls the virtual function of this or that derived class.
If the base and derived classes are of the same size, it is valid to access an array of derived-class objects though a pointer to the base class. .
Then the same object is checked for a nullptr value, though it is the object of the derived class that this check should have been applied to.
The virtual keywordis the function specifier, which provides a mechanism to select dynamically at runtime an appropriate function-member among the functions of basic and derived classes.
The public keyword after a colon in the header of a derived class indicates that the protected and public members of the base class CShape should be inherited as protected and public members of the derived class CCircle.
Thus, by declaring the most general members in the base class, we can add an additional members in derived classes, which specify a particular class. .