实现派生类构造函数时出错:"没有重载函数实例匹配指定类型

时间:2016-01-25 22:16:58

标签: c++ inheritance constructor

以下源旨在创建一个抽象基类(SubsystemClass)和一个派生的最终类(DisplaySubsystemClass)。派生类的构造函数的实现在出错时失败"没有重载函数的实例" DisplaySubsystemClass :: DisplaySubsystemClass"匹配指定的类型"。我很困惑。

SubsystemClass.hpp

#ifndef SUBSYSTEMCLASS_HPP
#define SUBSYSTEMCLASS_HPP

#include <memory>
#include "DriverClass.hpp"

class SubsystemClass 
{
protected:
    std::shared_ptr<DriverClass> _driver;
public:
    virtual ~SubsystemClass();
    enum DriverCatalog;
};

#endif

DisplaySubsystemClass.hpp

#ifndef DISPLAYSUBSYSTEMCLASS_HPP
#define DISPLAYSUBSYSTEMCLASS_HPP

#include <memory>
#include "../SubsystemClass.hpp"
#include "DisplayDriverClass.hpp"

class DisplaySubsystemClass final : public SubsystemClass
{
private:
    std::shared_ptr<DisplayDriverClass> _driver;
public:
    DisplaySubsystemClass(DisplaySubsystemClass::DriverCatalog driverCatalogItem);
    ~DisplaySubsystemClass();
    enum DriverCatalog {
        DISPLAY_DRIVER_CONSOLE,
        DISPLAY_DRIVER_CURSES,
        DISPLAY_DRIVER_SFML,
        DISPLAY_DRIVER_OPENGL
    };
};

#endif

DisplaySubsystemClass.cpp

#include <memory>

#include "DisplaySubsystemClass.hpp"
#include "SFMLDisplayDriverClass.hpp"
DisplaySubsystemClass::DisplaySubsystemClass(DisplaySubsystemClass::DriverCatalog driverCatalogItem)
{
}

DisplaySubsystemClass::~DisplaySubsystemClass()
{
}

1 个答案:

答案 0 :(得分:0)

枚举应在构造函数中用作参数类型之前声明。