Code:
Complex x, y, z;
x=y+z; /* temporary created */
In the above case you are using the = operator and that needs to be overloaded which should take care of creation of objects. The scenario where the temporary object come into picture are.
Code: CPP
#include <iostream.h>
class A
{
int i;
public:
A()
{
cout<<"A Constructor"<<endl;
}
~A()
{
cout<<"A Destructor"<<endl;
}
};
A func()
{
return A();
}
int main()
{
func();
cout<<"Now end of main"<<endl;
return 0;
}