Код: Выделить всё
#include
#include
#include
using namespace std;
class Base {
public:
virtual ~Base () {}
virtual double get() const = 0;
virtual void set() const = 0;
virtual void area() const = 0;
virtual void perimeter() const = 0;
virtual void PrintRectangleDimensions() const = 0;
};
template class Rectangle : public Base {
private:
T length, width;
public:
Rectangle(T val1, T val2) : length(val1), width(val2) {
this -> length = length;
this -> width = width;
}
double get(string dimension) {
if (dimension == "length") {
return length;
}
if (dimension == "width") {
return width;
}
};
void set(double value1 = 0, double value2 = 0) {
if (value1 != 0) {
length = value1;
}
if (value2 != 0) {
width = value2;
}
};
void area() {
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79894328/using-class-templates-and-base-class-functions-with-custom-classes[/url]