test program, dont understand after calling function it goes two times destructor "-5"
is it wrong ?
#include <cstdlib>
#include <iostream>
using namespace std;
class calculation
{
public:
calculation(); // constructor
~calculation(); // destructor.
};
calculation::calculation()
{
cout << "5"<<endl;
}
calculation::~calculation()
{
cout <<"-5"<<endl;
}
calculation function_one(calculation addition);
int main(int argc, char *argv[])
{
calculation erek;
cout <<" calling function_one"<<endl;
function_one(erek);
system("PAUSE");
return EXIT_SUCCESS;
}
// function oneeee.
calculation function_one(calculation addition)
{
cout << "addition function_one returning "<<endl;
return addition;
}