I know that coding with C, the return value of a function return to caller using %eax register.
With c++ it is also possible to return structs and not just 'Primitive' types, so when a function returns a struct, where is the returned value stored (stack, heap, etc)?
Example Code:
class Student
{
private:
int m_id;
public:
Student(int id)
{
m_id = id;
};
~Student();
int getId()
{
return m_id;
};
};
Student myFunc()
{
return Student(123);
}
int main()
{
//How does 'student1' get the value from the function?
//Does 'myFunc' write directly to the stack of main?
Student student1 = myFunc();
return 0;
}