I keep getting these stack overflow errors. I can only declare 50 of my 'ROOM' variables. if i add more variables to struct ROOM, that number goes down. it seems like theres not enough memory for the compiler or something. im using MSVC++ 6.
I keep getting these stack overflow errors. I can only declare 50 of my 'ROOM' variables. if i add more variables to struct ROOM, that number goes down. it seems like theres not enough memory for the compiler or something. im using MSVC++ 6.
Try declaring it like:
classname *ROOM = new classname[number_of_rooms];
That will allocate enough memory if you have it.
im not sure what you mean by that. possibly explain more? im using structs though, struct ROOM
uh im pretty sure you didnt run outta memory...
but i would dynamically allocate the struct when you are using them, that way you can check to see if the allocation worked, and if not then try reducing the size of the allocation...
in C++ is much better to dynamically allocate everyting, altho its tad slower for certain things, it gives you more control and felxibility with you code...
LB0: * Life once school is done
LB1: N <- WakeUp;
LB2: N <- C++_Code;
LB3: N >= Tired : N <- Sleep;
LB4: JMP*-3;
Hmmm, that's a tough one -
struct*ROOM = new ROOM[number_of_rooms];
or you could could set up your compiler to allocate more stack space (and before you ask someone how to do this, try reading a few manuals, or searching on google).
Or you could use any one of the standard container classes.
Or you could jack it all in.
Why is it better to dynamically allocate everything? Each pointer is 4 bytes + size of the object you're creating. Also, you have the overhead of deleting each one of the variables, instead of letting them take their own course of action and go out of scope.
This will work with small objects, in small applications.Originally posted by Dual-Catfish
Why is it better to dynamically allocate everything? Each pointer is 4 bytes + size of the object you're creating. Also, you have the overhead of deleting each one of the variables, instead of letting them take their own course of action and go out of scope.
BUT you have a limited stack. I'm not sure how big it is, if anyone knows please post it.
You are receiving a "stack overflow" message b/c .....umm......Its self explanatory.
You put too much in your stack. Think of it like an array.
Try to help all less knowledgeable than yourself, within
the limits provided by time, complexity and tolerance.
- Nor
actually i solved it a different, much easier way. declare each room as a static variable.
Having to manage 50 seperate variables (without them being consolidated into an array) is an easy solution I think...
was that supposed to be sarcastic....that IS what im doing. now i can have all 55 rooms. i never knew that when a variables is instantiated as static that it isnt put onto the stack.
ok leem man s plz change ur avatar i spent 2 hours!!!!!!!!!!! looking for that!!!!! i mean ur a senior u should have ur own
And the cows moo...
AIM:ProdigyCpp
E-Mail:[email protected]
If you like my avatar plz dont copy it go to:
http://www.dragid.com/
It wasn't sarcastic.. but I meant to have a not in there .