assume we have this struct and we need to take data from user , the type of the car and the car number, how can we read line nr 2 below, and how to read the code , I mean what does this code mean vector <string> type
1 2 3 4 5 6 7 8 9 10 11 12 13
struct Car {
vector <string> type;
int carNr;
};
// read data funtion
// I done this so far, got errors
void readData (Car & car) {
cout << "Enter the car type please", getline (cin, car.type);
}
Enter the car's type: This is a TEST
Car type: This is a TEST
Car #: 1
Having the car type be a vector of strings may be the requirement, but without knowing EXACTLY what your assignment is, ALL of it, using a vector to store a bunch of types makes ZERO sense. Especially since a car's number is a single entry.
Enter the car type please: Ford Coupe
Enter the car number please: 1234
Enter the car type please: Buick
Enter the car number please: 99878
Enter the car type please: Chevrolet Impale
Enter the car number please: 888
Ford Coupe 1234
Buick 99878
Chevrolet Impale 888
Program ended with exit code: 0