jeudi 23 juin 2016

error: base class 'A1' has private copy constructor

Using Clang 3.7 on windows platform

See following code:

class A1
{
public:
    A1(char* name){}
    virtual ~A1() {}
private:
    A1(const A1&) {}
};

class B1 : public A1
{
public:
    B1(): A1(""){}
};

I get the following error:

 MyFile(31): 8: error: base class 'A1' has private copy constructor
         B1(): A1(""){}
               ^
 MyFile(25): 2: note: declared private here
         A1(const A1&) {}
         ^

Making A1 copy constructor public, eliminates the error!

What happened here?

Note: that by changing (as I should)

A1(const char* name)

I get no errors and all compile as expected

Aucun commentaire:

Enregistrer un commentaire