How is memory organised when programming c++? what is dynamic and static memory? Where is it saved?
I like this question, Memory in C++ is organized into 3 categories. The stack, the heap and the text. The stack is used to push functions on top of each other creating scopes, but it also is a small memory reserve for those functions. Local variables use this memory. The heap is a place where uninitialized variables get there memory. Anytime you use the "new" keyword or make a call to a memory function in cstdlib, you are getting memory from the heap. The text is literally just text, this is the part of the program that holds your declarations, and all the text of your program. The stack is considered static memory, because it is set, and doesn't change. And the heap would be dynamic memory because it is always changing. All the memory is loaded into either the RAM of your computer or one of the three caches of your computer.
Globals, which I assume is what you're referring to, are like locals. When the program starts anything it finds globally are automatically pushed to the stack and will stay there until the program ends.
LMAO, I'm 19 bro😂😂
@SoraKatadzyma that's ......a bit...... too intense =,=.
@soraKatadzuma how can u answer soo... intense.... just being 10.... OMG
So if i create an instance of a class without the new-operator, it will be put into stack?
where are the variables stored that aren't created with new and aren't local variables in functions?
are these objects also accessed by the stack-pointer?
Problem Statement Given two integers a and b, your task is to calculate and print the following four values:
Please help, any idea?