I wrote this code and could someone explain how many objects are created in heap and stack? Is myStudent object in heap or stack? Second question, is main method itself and the things inside of main method stored in stack?
class Student
{
public:
Student()
{
id = 0;
}
private:
int id;
};
Student studentCreator()
{
Student* s = new Student();
return *s;
}
int main()
{
Student myStudent = studentCreator();
return 0;
}