3

The following source aims to create an abstract base class (SubsystemClass) and a derived final class (DisplaySubsystemClass). Implementation of the constructor for the derived class fails on error "no instance of overloaded function "DisplaySubsystemClass::DisplaySubsystemClass" matches the specified type". I am baffled.

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()
{
}
Daniel Lee
  • 189
  • 10

1 Answers1

0

The enumeration should be declared before its using as a parameter type in the constructor.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
  • @DanielLee The problem is that the error message is very confusing. – Vlad from Moscow Jan 25 '16 at 22:40
  • Perhaps. But I am not sure that becoming so dependent on quality error output is a good thing. I shifted this code around for several hours and failed to notice one of the most basic mistakes; using a variable before it is defined. That said, I am finding Visual Studio is not very helpful at all in this regard. – Daniel Lee Jan 25 '16 at 22:50