There is a code:
#include "stdafx.h" #include <iostream> #include <math.h> #include <string> using namespace std; class Auto { public: double inc; double Auto1(double a, double b, string val) { inc = b - a; cout << "Прибыль: " << inc << val << endl; return inc; } }; class BMW : public Auto { public: void BMW1() { cout << "Престиж: " << inc <<" престижей"<< endl; } }; int main() { double a, b,inc; string val; setlocale(LC_ALL, "rus"); cout << "Введите затраты на производство одного автомобиля: " << endl; cin >> a; cout << "Введите стоимость покупки: " << endl; cin >> b; cout << "Введите валюту: " << endl; cin >> val; Auto s1; s1.Auto1(a, b, val); BMW s2; s2.BMW1(); system("pause"); return 0; } How to inherit the inc variable in the BMW class? Explain, please. Thank you in advance!
incyou have a variable that is not static, so changing it ins1, ins2you won’t get it. Classes themselves do not bear any load, you simply tied them with "strings", just to be ... - Harry