Could someone explain how to use a copy constructor.
Could someone explain how to use a copy constructor.
Google can. Here's the first hit you get.
Quzah.
Hope is the first step on the road to disappointment.
Dont mean to sound cynical here, but isnt the point of a forum to have human interaction in this anti-social environment computers put us in? I think you will find a lot of questions here can be answered in their books/google/searching this site maybe we should ease up a tad? When users dont bother to read guidlines etc i can understand why frequent viewers get upset. When it comes to questions maybe we should just search.
Meg: Everybody! Guess what I am?
Stewie: Hm, the end result of a drunken back-seat grope-fest and a broken prophylactic?
Thank you, but i already have the syntax. I just wanted a better explanition than what my incompatent teacher could give me.
I gave him a link to it. Why reinvent the wheel? It's already typed up. I gave a direct link to some one else's explanation. If you don't like it, shut up, or type it up your self.
Or are you just ..........ing to ..........? Because I actually provided something useful. You provided nothing at all useful to this conversation.
Quzah.
Hope is the first step on the road to disappointment.
The link I provided explains them well. Since you apparently can't read what they wrote, don't ask me why, I'll explain it yet again. Though I'm not sure you'll be able to read this, because you apparently couldn't read that.
A copy constructor is called when you create a new instance of an object based off of that object. That is to say:
*Assuming you actually have your copy constructor do something. Because you could make it do nothing.Code:class Foo f; // 'f' is created with the default constructor. class Foo b = f; // 'b' uses a copy constructor to copy the values of 'f' into 'b'.*
What's so hard about that?
Quzah.
Hope is the first step on the road to disappointment.
Your right i couldn't read. Well i can just takes a while to sink in. After reading it about 10 times I now understand. Thanks
Last edited by jspringart; 02-06-2005 at 11:54 PM.
I didnt want to start an argument and you did provide a good link so there was no more to add to this thread other then a small example of what i think happens too often here, who am i to judge though, you obvously disagree, everyone has an opinion i might keep them to my self next time.
Meg: Everybody! Guess what I am?
Stewie: Hm, the end result of a drunken back-seat grope-fest and a broken prophylactic?
Remember also, that copies of objects are made, (or multiple copies), whilst passing objects as parameters to functions or returning them from functions, although this may not be apparent.
A copy constructor is a wise investment for all but the simplest of classes.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.