lundi 25 mai 2020

Default copy constructor and linking errors C++ [closed]

I have a class that looks like:

class A{
private:

vector<double> v;

public:

      //constructor and various functions

   `};`

I'm questioning whether to write a copy constructor: I think it is not necessary because I do not have any pointer in this class, so the default copy constructor should be okay. But I observe that if I do not redefine the copy constructor, each time a copy of a member of this class is created in another class (eg: returning a memeber of classA in a function of a classB), I get a linker error. If I explicit the copy constructor, I don't get this error. Why is that? and would it be advisable so to explicit or not to explicit the copy constructor?

Thanks

Aucun commentaire:

Enregistrer un commentaire