'C++ Compile error:'HelpModel' was not declared in this scope - using an optional

I'm getting the following error when compiling, using GCC 11.2.0:

/src/SearchController.h:12:23: error: ‘HelpModel’ was not declared in this scope
   12 |         std::optional<HelpModel> searchModel;
      |                       ^~~~~~~~~
/src/SearchController.h:12:32: error: template argument 1 is invalid
   12 |         std::optional<HelpModel> searchModel;
      |                                ^

I'm including the HelpModel class in the header, but this is pretty much my first C++ program so my understanding of this is pretty thin at the min.

Here's the SearchControlle.h file

#ifndef ARCH_HELP_SEARCH_CONTROLLER
#define ARCH_HELP_SEARCH_CONTROLLER

#include <string>
#include <optional>

#include "HelpModel.h"

class SearchController
{
    public:
        std::optional<HelpModel> searchModel;
        void searchedFor(std::string searchTerm);
};

#endif

And here's the HelpModel.h file:

#ifndef ARCH_HELP_HELP_MODEL
#define ARCH_HELP_HELP_MODEL

#include <vector>
#include "Topic.h"
#include "TerminalView.h"

class HelpModel 
{
    public:
        HelpModel(TerminalView view);

    private:
        TerminalView view;
        std::vector<Topic> topics;
        void getTopics();
        void pushToView();
};

#endif

Here's TerminalView.h

#ifndef ARCH_HELP_TERMINAL_VIEW
#define ARCH_HELP_TERMINAL_VIEW

#include <vector>
#include <string>
#include "SearchController.h"
#include "Topic.h"

class TerminalView
{
    public:
        void makeHeader();
        void update(std::vector<Topic> modelData);
    
    private:
        std::string searchTerm;
        std::vector<Topic> helpData;
        SearchController controller;
        void makeSearchInput();
        void printToTerminal();
        void printAnswers(std::vector<std::string> answers);
};

#endif

What I would like to be able to do is then assign an instance of HelpModel to the SearchController like so - say in main.cpp:

HelpModel model(terminal);
SearchController controller;
controller.searcModel = model;

Any advice greatly appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source