No supposedly output shown

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Vehicle{
    string manager;
 public:
    Vehicle(string manager) : manager(manager){}
    void setManager()       {this->manager=manager;}
    string getManager()     {return manager;}
};

class Car : public Vehicle{
    string model;
    string manufacturer;
    string plate;
    string manager;
    long price;
 public:
    Car(string model, string manager = "Not Asigned") :
        model(model), Vehicle(manager){}
    void setModel(string model)                 {this->model = model;}
    void setManager(string manager)             {this->manager = manager;}
    string getModel()                           {return model;}
    string getManager()                         {return manager;}
};

int main(){
    vector<Vehicle> Managers;
    vector<Car> Cars;
    int countVehicle = 0;

    Managers.push_back(Vehicle("Trevor"));
    Managers.push_back(Vehicle("Michael"));
    Managers.push_back(Vehicle("Caine"));

    Cars.push_back(Car("Car1", Managers[0].getManager()));
    countVehicle++;
    Cars.push_back(Car("Car2", Managers[1].getManager()));
    countVehicle++;
    Cars.push_back(Car("Car3", Managers[1].getManager()));
    countVehicle++;

    cout <<"1234 "<< Cars[2].getManager() << "1234 " << endl;
}


Supposedly the output should be 1234 Michael 1234.
But when I built n run the program, the program only show 1234
What is wrong with my code?
You may want to increase your compiler warning level and fix the warnings:

main.cpp||In constructor ‘Vehicle::Vehicle(std::string)’:|
main.cpp|11|warning: declaration of ‘manager’ shadows a member of 'this' [-Wshadow]|
main.cpp|16|warning: base class ‘class Vehicle’ has a non-virtual destructor [-Weffc++]|
main.cpp||In constructor ‘Car::Car(std::string, std::string)’:|
main.cpp|23|warning: declaration of ‘manager’ shadows a member of 'this' [-Wshadow]|
main.cpp|23|warning: declaration of ‘model’ shadows a member of 'this' [-Wshadow]|
main.cpp|17|warning: ‘Car::model’ will be initialized after [-Wreorder]|
main.cpp|24|warning: base ‘Vehicle’ [-Wreorder]|
main.cpp|23|warning: when initialized here [-Wreorder]|
main.cpp|23|warning: ‘Car::manufacturer’ should be initialized in the member initialization list [-Weffc++]|
main.cpp|23|warning: ‘Car::plate’ should be initialized in the member initialization list [-Weffc++]|
main.cpp|23|warning: ‘Car::manager’ should be initialized in the member initialization list [-Weffc++]|
main.cpp|23|warning: ‘Car::price’ should be initialized in the member initialization list [-Weffc++]|
main.cpp||In member function ‘void Car::setModel(std::string)’:|
main.cpp|25|warning: declaration of ‘model’ shadows a member of 'this' [-Wshadow]|
main.cpp||In member function ‘void Car::setManager(std::string)’:|
main.cpp|26|warning: declaration of ‘manager’ shadows a member of 'this' [-Wshadow]|
||=== Build finished: 0 errors, 13 warnings (0 minutes, 1 seconds) ===|


Comment out line 21. What happens to your output? Why?

How do lines 2 and 13 interact?
Topic archived. No new replies allowed.