Quote:
when will the desructor function base::~base will be called for b1 ?
Is it at end the function fun(base b1) ?
Or the end of main() ?
b1 is a parameter of a function. Function parameter names are local variables of the function, and they are initialized with the values you send to the function. That is why the types of the values you send to a function must match the types of the parameter variables. When the function ends, all the local variables are destroyed. So, the destructor for b1 is called when the function ends.