gpt4 book ai didi

c++ - 错误实现派生类构造函数 : "No Instance of Overloaded Function Matches the Specified Type

转载 作者:太空狗 更新时间:2023-10-29 23:14:12 26 4
gpt4 key购买 nike

以下源代码旨在创建一个抽象基类 (SubsystemClass) 和一个派生最终类 (DisplaySubsystemClass)。派生类的构造函数的实现失败,出现错误“重载函数“DisplaySubsystemClass::DisplaySubsystemClass”的实例与指定类型不匹配”。我很困惑。

子系统类.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

显示子系统类.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

显示子系统类.cpp

#include <memory>

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

DisplaySubsystemClass::~DisplaySubsystemClass()
{
}

最佳答案

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

关于c++ - 错误实现派生类构造函数 : "No Instance of Overloaded Function Matches the Specified Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35003471/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com