Let's consider the following code:
#include <bits/stdc++.h>
using namespace std;
class Temp
{
public:
Temp()
{
cout<<"Inside constructor.\n";
}
~Temp()
{
cout<<"Inside destructor.\n";
}
};
int main()
{
Temp();
return 0;
}
In this code, we are calling constructor explicitly. Now my question is, why would we need to call the constructor explicitly? And why would C++ allow us to do so?