I get this erorr: VC++ — This declaration has not storage class or type specifier in the line:
towerControl.push_back() = new Boeing;
Can somebody point out what’s going wrong? Thanks.
#include <iostream>
#include <vector>
using namespace std;
class Aircraft {
public:
virtual void disp() { cout << "I'm an aircraft\n"; }
virtual ~Aircraft() { cout << "Aircraft::Destructor\n"; }
};
class Boeing: public Aircraft {
public:
void disp() { cout << "I'm a Boeing\n"; }
~Boeing() { cout << "Boeing::Destructor\n"; }
};
class Airbus: public Aircraft {
public:
void disp() { cout << "I'm an Airbus\n"; }
~Airbus() { cout << "Airbus::Destructor\n"; }
};
class Tower {
public:
vector <Aircraft*> towerControl;
towerControl.push_back() = new Boeing;
towerControl.push_back() = new Airbus;
~Tower() { cout << "Tower::Destructor\n"; }
};
int main() {
Tower T;
}
Sure. The syntax is wrong. It should be:
And you also need to call it inside a member of
Tower, possibly a constructor:Seems to me like you need to start learning the basics of C++.