Flights is a three-dimensional array because it has three stars. If what you really want is a 2d array then remove one of the asterisks in its declaration.
Ancient Dragon
Retired & Loving It
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
> *(Flights+i)=new int *[size];
> *(Flights+i)=flightNo; //this is the error place
Well these two lines are both accessing the same thing, and only the first one is correct.
> my problem is that Flights[a][b][c]=flightNo, this is the error
So write it like that then
Flights[x][y][z] = flightNo;
You're not buying anything with overly complicated pointer expressions involving lots of *'s, +'s and parentheses. It's all the same to the compiler.
But in order to do that, you need a 3rd level of allocation, namely Flights[x][y] = new int[numZeds];
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
What you've got there, looks like a recipe for disaster.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Use std::vector and get rid of all those messy pointers and memory allocations.
A flight consists of X number of rows of N number of seats. You can express that in c++ vector class by
vector< vector<int> > Flight;
Ancient Dragon
Retired & Loving It
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342