What will be the output?
#include <iostream>
class Sample {
public:
~Sample() {
std::cout << "Destructor executed\n";
}
};
void createObject() {
Sample s;
}
int main() {
createObject();
std::cout << "Main done\n";
}
Main done
Destructor executed
Destructor executed
Main done
Main done
Destructor executed
This question is part of this quiz :
C++ Destructors,Constructors & Destructor,Constructors, Destructors, and this Pointer