Here I call the constructor of the class ain main()without creating an object of this class, and it looks like the destructor is called right after the call. What is really going on here? In my understanding, is this because I did not create an object with some memory? What is called dtor here? How is this implemented? Share your thoughts on this.
#include<iostream>
using namespace std;
class a{
public:
a(){
cout<<"\nctor";
}
~a(){
cout<<"\ndtor";
}
};
int main(){
a();
cout<<"\nctor_called\n";
}
o / p programs:
ctor
dtor
ctor_called
source
share