简体   繁体   English

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

[英]Error Implementing Derived Class Constructor: "No Instance of Overloaded Function Matches the Specified Type

The following source aims to create an abstract base class (SubsystemClass) and a derived final class (DisplaySubsystemClass). 以下源旨在创建一个抽象基类(SubsystemClass)和一个派生的最终类(DisplaySubsystemClass)。 Implementation of the constructor for the derived class fails on error "no instance of overloaded function "DisplaySubsystemClass::DisplaySubsystemClass" matches the specified type". 派生类的构造函数的实现失败,错误“没有重载函数的实例”DisplaySubsystemClass :: DisplaySubsystemClass“匹配指定的类型”。 I am baffled. 我很困惑。

SubsystemClass.hpp 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 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 DisplaySubsystemClass.cpp

#include <memory>

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

DisplaySubsystemClass::~DisplaySubsystemClass()
{
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有重载 function 的实例与指定类型匹配 (C++) - no instance of overloaded function matches the specified type (C++) 派生类中的重载构造函数 - Overloaded constructor in derived class 没有重载函数“ CVector4 :: operator”的实例与指定类型匹配/项不求值为带有2个参数的函数 - No instance of overloaded function “CVector4::operator” matches the specified type / term does not evaluate to a function taking 2 arguments 没有重载函数“”的实例与参数列表错误匹配 - no instance of overloaded function “” matches the argument list error 错误:构造函数(C ++)中没有重载函数的实例 - Error: no instance of overloaded function, in constructor (C++) 派生类的新构造函数未构建:“未找到重载的成员函数” - Derived class's new constructor not building: “overloaded member function not found” 没有功能模板的实例与指定类型匹配 - No instance of function template matches the specified type 直接类型转换为派生到基类以调用重载函数 - Directly type cast derived to base class to call overloaded function 错误:多个重载函数实例与参数列表匹配 - Error: more than one instance of overloaded function matches argument list 错误没有重载函数的实例“getline”匹配参数列表c ++ - error no instance of overloaded function “getline” matches the argument list c++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM