Why I can't use my custom header file? The IDE marks the include as unused. In C++ I have very mediocre knowledge. Perhaps I misunderstand something and incorrectly implement the .h and .cpp files.
There is a header file describing the structure of the mgportfolio.h class:
class LIBMGPORTFOLIO_EXPORT MgPortfolio : IComponent
{
public:
MgPortfolio();
explicit MgPortfolio();
~MgPortfolio();
void accept(IVisitor& visitor) override;
private:
//std::string m_portfolioFilePath;
//std::string m_portfolioName;
//std::string m_owner;
};
Next, I want to implement a pattern "visitor" for some of my logic. I add one more header file visitor.h:
#pragma once
#include "portfoliooption.h"
#include "playlistitem.h"
#include "archiveddata.h"
#include "mgportfolio.h" //Ide underlines this header file as unused. Although in the first visit() method I use the object from this file.
namespace mg
{
class IVisitor
{
public:
virtual ~IVisitor() = default;
virtual void visit(MgPortfolio& portfolio) const; //here the ide suggests including #include "mgportfolio.h" but I already did that above.
virtual void visit(PortfolioOption& portfolioOption) const; //here and below the header file is connected without problems
virtual void visit(PlaylistItem& playlistItem) const;
virtual void visit(ArchivedData& archivedData) const;
};
class IComponent
{
public:
virtual ~IComponent() = default;
virtual void accept(IVisitor& visitor) = 0;
};
}
The PortfolioOption, PlaylistItem, ArchivedData classes differ from MgPortfolio only in that they do not have an implementation in .cpp files. As soon as I add the implementation, the same error appears as with MgPortfolio.What could be my problem?