0

Help! Topic: inheritance, derived classes in C++. CAN someone explain the error" calling a private constructor, has_abs is priv

#include <iostream> #include <cstring> using namespace std; class Vehicle { public: std::string name() { return name_; } int number_of_wheels() { return number_ofwheels; } std::string propulsion_type() { return propulsiontype; } double max_speed() { return maxspeed; } protected: Vehicle(const std::string &name, int number_of_wheels, const std::string &propulsion_type, double maxspeed) : name(name), number_ofwheels(number_of_wheels), propulsiontype(propulsion_type), maxspeed(maxspeed) {} std::string name; int number_ofwheels; std::string propulsiontype; double maxspeed; }; class Bike : public Vehicle { public: Bike() : Vehicle("Bike", 2, "Muscles", 30) {} }; class Plane : public Vehicle { Plane(const std::string &name, const std::string &propulsion_type, double max_speed, bool has_abs) : Vehicle(name, 4, propulsion_type, max_speed), hasabs(has_abs) {} bool has_abs() { return hasabs; } private

31st May 2020, 9:31 AM
Reynolds Onyango
Reynolds Onyango - avatar
2 odpowiedzi
0
Can You link the code instead of writing it down? That way we can execute it (furthermore it is not complete). Errors I found yet: Variable name is sometimes also called name_ Function and variable both with same name (name)
31st May 2020, 9:56 AM
Michi
Michi - avatar
0
Here is a link to discord where I have uploaded the code https://discord.gg/7XSPmD
31st May 2020, 10:28 AM
Reynolds Onyango
Reynolds Onyango - avatar