ok here is my following program:
#include <iostream>
using namespace std;
class Aircraft
{
private:
int range;
public:
Aircraft(int r) {range = r;}
~Aircraft() {cout << range << endl;}
};
class Airplane
{
private:
int length;
public:
Airplane(int l) {length = l;}
~Airplane() {cout << length << endl;}
};
class Helicopter
{
private:
int clearance;
public:
Helicopter(int c) {clearance = c;}
~Helicopter() {cout << clearance << endl;}
};
int main()
{
Aircraft carrier(5);
Airplane bowan(9);
Helicopter apache(15);
}
now the next thing that needs to be done is create a 5 element array of pointers to Aircraft. Then using the new operator, create dynamically 1 helicpoter, 3 Airplanes, and 1 Aircraft object. Than assign these objects to the elemtns of the array. Than in a loop delete each object...im assumign delete[] can work with that?
i understand id have to do
Aircraft *p[5];
but how would i go about intialising the new statements?
i tried p[5] = new helicopter;
but that just winds up giving me alot of errors
how can i go about doing this?