What's wrong with this?
I am trying to allocate a dynamic array of pointers to classes. Therefore I create a pointer to a pointer and allocate the array to it with the new operator, thus:
input = new (*inPort [inputs]);
But the compiler comes up with three errors:
'cannot convert int * * to inPort * *'
'type name expected'
'statement missing ; '
All three errors are for the same line.
..this might help.
//This creates an array of pointers to input objects
//access example i[ n ]->MyFunction();
i = new input*;
for(int j = 0; j < 10; j++)
i[j] = new input;
//This on the other hand creates an array of objects
//access example is i[ n ].MyFunction();
//this is what you might want
//I would use the ** only in two ocassions
//... 1. to create a two dimensional array
//... 2. as a parameter in a function to modify say the root
//... of a tree... but with C++ the obj &myObj eliminates the need for the 2nd case
i = new input;
Man, THANK YOU!
I can't believe it was such a simple mistake. I had the star in the wrong place. I was tearing my hair out over that, too.