You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exercise 13.1.4 ask for the member data is uniuqe serial number for numbered class. By looking your code.it could happens the identical numbers among different objects. as follow.
` numbered a, b = a, c = a;
f(a);//10
f(b);//11
f(c);//11
I think about one way to solve it. defined a static member data in numbered. First initializes zero to it outside class numbered. The static member initializes the unique serial number ,and then increment it, for whatever copy constructor or copy assignment-operator.
The text was updated successfully, but these errors were encountered:
As per the problem statement, output will be similar for all the cases.
Since synthesized copy constructor will basically copy the unique value of mysn object "a" to other objects.
So, if a.mysn = 999
Then f(a);//999
f(b);// 999
f(c);//999
Exercise 13.1.4 ask for the member data is uniuqe serial number for numbered class. By looking your code.it could happens the identical numbers among different objects. as follow.
` numbered a, b = a, c = a;
f(a);//10
f(b);//11
f(c);//11
I think about one way to solve it. defined a static member data in numbered. First initializes zero to it outside class numbered. The static member initializes the unique serial number ,and then increment it, for whatever copy constructor or copy assignment-operator.
The text was updated successfully, but these errors were encountered: