How to make multiple classes

Dec 15, 2018 at 7:15pm
Can someone help.I have been struggling with this for hours can't figure it out how to make it work.Here is my code:

#include <iostream>

using namespace std;
class BMWClass{
public:
void SetName(string BMW){
name = BMW;
}
string getName(){
return name;
}
private:
string name;
};




class BMWDoorClass{
public:
void SetName(string BMWDoor){
name = BMWDoor;
}
string getName(){
return name;
}
private:
string name;
};

int main()
{

BMWClass bo;
bo.SetName("Needs repair");
cout <<bo.getName();
return 0;

BMWDoorClass bo;
bo.SetName("Broken door and 4 windows damaged");
cout <<bo.getName();
return 0;




}



Dec 15, 2018 at 7:19pm
You can't declare two variables with the same name within the same scope.
Dec 16, 2018 at 2:21pm
So far, classes BMWClass and BMWDoorClass don't add any functionality to class string. In other words, you could use string instead of your new classes. Hopefully you plan to add functionality to these classes in the future.
Dec 16, 2018 at 4:16pm
Thanks guys you were helpful.
Topic archived. No new replies allowed.