Can vectors really hold classes?
-
Hello everyone! OK, I have:
vector<Vehicle> vehicles;
ClassVehicle
doesn't have a constructor. However, when I add a constructor, I get this error on the line in whichvehicles
is declared (see above):1>c:\incoming\war game\Game.h(11) : error C2065: 'Vehicle' : undeclared identifier
The declaration of the constructor is as follows:Vehicle(int x, int y, int id);
What is wrong with this code? Thanks!Windows Calculator told me I will die at 28. :(
-
Hello everyone! OK, I have:
vector<Vehicle> vehicles;
ClassVehicle
doesn't have a constructor. However, when I add a constructor, I get this error on the line in whichvehicles
is declared (see above):1>c:\incoming\war game\Game.h(11) : error C2065: 'Vehicle' : undeclared identifier
The declaration of the constructor is as follows:Vehicle(int x, int y, int id);
What is wrong with this code? Thanks!Windows Calculator told me I will die at 28. :(
If you don't add a constructor, the compiler automatically adds an emtpty one for you. Add an empty constructor to your class, and it should work.
-
If you don't add a constructor, the compiler automatically adds an emtpty one for you. Add an empty constructor to your class, and it should work.
That's the problem - if I add an (empty) constructor, it gives me the error... It's error-free when I
don't
add one. ;PWindows Calculator told me I will die at 28. :(
-
That's the problem - if I add an (empty) constructor, it gives me the error... It's error-free when I
don't
add one. ;PWindows Calculator told me I will die at 28. :(