June 2025
Intermediate to advanced
1093 pages
33h 24m
English
In C++, there are special class forms that help you structure your code. Abstract classes and methods allow you to define an interface first without implementing it. Enumeration classes, in turn, bundle possible values of a class.
You learned about virtual methods in Chapter 15. With these, you can do something very special—namely, methods without implementation.
// https://godbolt.org/z/1zq4jfdYb#include <string>#include <iostream>using std::string; using std::ostream;class Shape { string color_;public: virtual double calcArea() const = 0; // pure virtual method string getColor() const { return color_; } void setColor(const string& color) { color_ = color; } virtual ~Shape ...
Read now
Unlock full access