ikl wrote:
Is it right to define an array of pointers pointing to a list of objects
like this?
class A
{
};
A* ptr[15];
int i = 0;
for(i=0; i<15; ++i){
ptr[i] = new A();
}
If the items are all the same type, as is the case here, then there's no
need for pointers at all. You could simply create the array this way:
A some_array[15];
Or use a std::vector, as others suggested. This is preferable in most
cases, because of the increased flexibility and ease of use.
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.