Hello I have two files that define classes. In one of them I am trying declare an array of classes of another class using a pointer, I have some troubles with syntax, how I declare this in the first file? thank you in advance
the first file :
#ifndef YARD_H_INCLUDED
#define YARD_H_INCLUDED
#include <iostream>
using namespace std;
class yard
{
public:
int yard_size;
car *car_array[];
int cars_in_yard;
yard();
void show() const
{
for (int i=0; i<=cars_in_yard;i++)
{
car_array[i]->show();
}
}
~yard()
{
yard_size=0;
delete car_array[cars_in_yard];
cars_in_yard= 0;
}
};
#endif // YARD_H_INCLUDED'
the second one is:
#ifndef CAR_H_INCLUDED
#define CAR_H_INCLUDED
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
class car
{
public:
char car_name[80];
double price;
int eng;
car();
void show() const
{
cout<<"Car Make : "<< *car_name <<" , Price: "<< price<<" , Engine : "<< eng <<" , cc";
}
};
car::car()
{
car_name[0]=0;
price=0.0;
eng=0;
}
#endif // CAR_H_INCLUDED'
std::vector<car> car_array#include "car.h"is missing in the first file.yard::yard()defined?