View Single Post
Old Oct 24th, 2006, 2:39 PM   #8
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Eric the Red View Post
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";
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote