This does become an issue however when working with references. Try to find out for yourself what could happen to the arguments of type Bar in the following methods:
Well, it looks like in the first example, b won't get changed where in the second example it could get changed. I guess I'm overthinking this const-correctness thing ![]()
However, I (think) I still don't understand the uses of the copy ctor/assignment op;
class Foo{
private:
int data
public:
/*normal ctor*/
Foo(int d) : data(d) {};
/*copy ctor*/
Foo(const &Foo copy) : data(copy.data){};
/*assignment op*/
Foo& operator=(const &Foo copy){ data = copy.data };
};
is the above correct?
if so, what do they have to do with dynamically allocated memory?
Foo *_ptr = new Foo(); /*does this create a whole new space in memory for test? if it does, am I correct in saying that the default assign op only makes test point to the same area of memory as _ptr - hence the whole deal about copy assignment operators?*/ Foo test = *_ptr;