mercredi 18 septembre 2019

Inheritance of =delete functions

let's say I have a class named File. I want to disable the copy constructor for every son of File, for example TextFile.

Would doing something like this will still disable the copy constructor of TextFile?

class File {
public:
    File(const File& f) = delete;
};

class TextFile:public File {
public:
};

Or is this necessary in order for this to be disabled?

class File {
public:
    File(const File& f) = delete;
};

class TextFile:public File {
public:
    TextFile(const TextFile& tf) = delete;
};

Aucun commentaire:

Enregistrer un commentaire