#include <iostream>
using namespace std;
class Test
{
public:
Test() { cout << "Constructor i`enter code here`s executed\n"; }
~Test() { cout << "Destructor is executed\n"; }
};
int main()
{
Test(); // Explicit call to constructor
return 0;
}
in above code we are calling constructor explicitly and When the constructor is called explicitly the compiler creates a nameless temporary object and it is immediately destroyed. why do we need this temporary object??
Aucun commentaire:
Enregistrer un commentaire