lundi 25 janvier 2016

constructor inheritance with C++11 compiler is generating error

I am trying to compile the following code (taken directly from wikipedia) to understand constructor inheritance in C++11 :

class BaseClass {
    public:
    BaseClass(int value);
};

class DerivedClass : public BaseClass {
    public:
    using BaseClass::BaseClass;
};

I am compiling this file as follows :

/usr/bin/g++-4.7 -c -std=c++11 file.cpp

But this is giving the following error :

error: ‘BaseClass::BaseClass’ names constructor

I do not know where am I going wrong

Aucun commentaire:

Enregistrer un commentaire