Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it seems has a lot problem. #86

Closed
ggandycong opened this issue Nov 2, 2016 · 1 comment
Closed

it seems has a lot problem. #86

ggandycong opened this issue Nov 2, 2016 · 1 comment

Comments

@ggandycong
Copy link

ggandycong commented Nov 2, 2016

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.

@Thor-repo
Copy link

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

@pezy pezy closed this as completed Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants