I am trying to play a little bit with memory in C++, I have defined myself a class and then I create an instance of that class inside of heap.
#include <iostream>
class mojeTrida {
public:
void TestPrint()
{
std::cout << "Ahoj 2\n";
}
};
int main() {
mojeTrida *testInstance = new mojeTrida();
testInstance->TestPrint();
std::cout << "Hello World!\n";
}
If I understand c++ correctly, anytime I am calling the keyword “new”, I am asking OS to give me certain amount of bytes to store a new instance of class inside of heap.
Is there any way I can store my class inside of stack?