Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Copy constructor/Assingment Operator

Name: Anonymous 2010-02-10 13:36

Hey /prog/, I am having some doubts about a class I'm making.

This class has an array of pointers to an struct. To make my life easier, I'm using std::vector for this. My doubt is coming from the assignment operator and copy constructor.

How would I handle both of these? I mean, std::vector has its own assignment operator but I am not sure if this would generate a shallow or deep copy of data which it holds (Which are pointers).

Name: Anonymous 2010-02-10 14:08

It holds the pointer, which is merely an address of where heap data is. Why would it generate a deep copy of the heap data? Even in the context of smart pointers, it wouldn't generate a deep copy. Your question is bad and you should feel bad.

If you're storing pointers, make sure you handle the pointers internally - creation and destruction. Otherwise you'll have a complex resource usage scheme and those are prone to failure.

Name: Anonymous 2010-02-10 14:58

C++, now you have 2 problems

Name: Anonymous 2010-02-10 16:00

How much time will you waste fucking around with sepples bullshit when you could just use a language that doesn't force you to be a human compiler?

Name: Anonymous 2010-02-10 20:31

>>1
How would I handle both of these?
You wouldn't. Your operators will not be invoked, because the vector is storing pointers, not objects. It already knows how to copy pointers; it's just a number after all.

>>4
this

Don't change these.
Name: Email:
Entire Thread Thread List