I checked this code, and i saw that by the end of the function func() the destructor of base class have been called twice. I dont understand why?? thank you..
class base {
public:
base(){cout << "ctor of base\n";}
~base(){cout << "d-ctor of base\n";}
};
class derived: public base
{
public:
derived(){cout << "ctor of derived\n";}
~derived(){cout << "d-ctor of derived\n";}
};
void func(base ob)
{
cout << "inside func\n";
}
void main()
{
derived ob;
func(ob);
system("pause");
}