C++17 Quick Syntax Reference by Mikael Olsson

C++17 Quick Syntax Reference by Mikael Olsson

Author:Mikael Olsson
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


Mikael Olsson1

(1)Hammarland, Finland

Inheritance allows a class to acquire the members of another class. In the following example, Square inherits from Rectangle. This is specified after the class name by using a colon followed by the public keyword and the name of the class to inherit from. Rectangle then becomes a base class of Square, which in turn becomes a derived class of Rectangle. In addition to its own members, Square gains all accessible members in Rectangle, except for its constructors and destructor.

class Rectangle

{

public:

int x, y;

int getArea() { return x * y; }

};



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.