Mar 8, 2010 at 8:29pm UTC
hey guys im trying to make a few inheritance classes
for aircrafts for an assignment
and it was working seemlessly until tried adding more classes and storing them in a vector and now im getting A WHOLE MESS of errors this is the code if any one can offer some advice that would be appreciated
Last edited on Mar 8, 2010 at 9:19pm UTC
Mar 8, 2010 at 8:53pm UTC
i figured it out i didnt put #include <vector>
in my header lol... oops... and i didnt declare the Aircraft's in my main.. function....
this is my new code no errors
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Vehicles
{
public :
};
class Aircraft
{
public :
bool useWeapons;
string name;
};
class Stealthfighter : public Aircraft
{
public :
};
class SR71Blackbird : public Aircraft
{
public :
string name;
};
class Stealthbomber : public Aircraft
{
public :
};
class Harrier : public Aircraft
{
public :
};
class F104Starfighter : public Aircraft
{
public :
};
class Attackhelicopter : public Aircraft
{
public :
};
class Apache : public Aircraft
{
public :
};
class Blackhawk : public Aircraft
{
public :
};
class Cobra: public Aircraft
{
public :
};
void main()
{
Aircraft Stealthfighter;
Aircraft SR71Blackbird;
Aircraft Stealthbomber;
Aircraft Harrier;
Aircraft F104Starfighter;
Aircraft Apache;
Aircraft Blackhawk;
Aircraft Cobra;
Stealthfighter.name = "Ge7 SHo7 DoWn" ;
Stealthfighter.useWeapons = true ;
vector<Aircraft> AircraftList;
AircraftList.push_back(Stealthfighter);
AircraftList.push_back(SR71Blackbird);
AircraftList.push_back(Stealthbomber);
AircraftList.push_back(Harrier);
AircraftList.push_back(F104Starfighter);
AircraftList.push_back(Apache);
AircraftList.push_back(Blackhawk);
AircraftList.push_back(Cobra);
cout << Stealthfighter.name << endl;
}
Last edited on Mar 8, 2010 at 9:03pm UTC
Mar 8, 2010 at 9:05pm UTC
That code also doesn't use any of your derived classes. They're all generic aircrafts.