Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Normal
In main, if I change [code]*a = *b;[/code] to [code]a = b;[/code], everything works as expected. The second "a" output is 7. This make sense in the context of "slicing" from Savitch. How do I go about both making a deep copy of b and also maintaining the polymorphism?A virtual Clone function! Why didn't I think of that?http://www.informit.com/articles/article.aspx?p=31529&seqNum=5 Thanks to everyone who knows the answer but never got a chance to give it...
In main, if I change [code]*a = *b;[/code] to [code]a = b;[/code], everything works as expected. The second "a" output is 7. This make sense in the context of "slicing" from Savitch.
How do I go about both making a deep copy of b and also maintaining the polymorphism?
A virtual Clone function! Why didn't I think of that?http://www.informit.com/articles/article.aspx?p=31529&seqNum=5 Thanks to everyone who knows the answer but never got a chance to give it...