Does C++ compiler use the default destructor when instances created on a stack are out of their scope? I am a bit confused because I assumed destructor is called when memory is allocated on a heap. I used the code example below.
enum Stage{starter, inbetween, graduating};
class Student
{
public:
Student(const std::string & a_name, Stage a_stage);
private:
const std::string name;
};
and in the main
int main( void )
{
Student s1{"Konjit", graduate}; // student instance on stack
return 0;
}