Quote:
Originally Posted by Eric the Red
Sorry, I meant
Cat * aRover = new Cat[300000]; // doesn't crash program
//Cat aRovert[300000]; // does crash program. The first line doesn't crash the program. While, if don't comment out the second line, it crashes.
|
Again, the first declares a bunch of pointers, whereas the second declares a bunch of Cat objects. Try adding this to see the difference:
std::cout << "300000 pointers to Cat = " << 300000 * sizeof(Cat*) << " bytes needed\n";
std::cout << "300000 actual Cat objects = " << 300000 * sizeof(Cat) << " bytes needed\n";