lundi 9 janvier 2017

Class inheritance in nested namespaces in C++ QT

I'm trying to make a well structured and clean code of application where namespaces order would indicate where to find certain class implementation files. I tried every possible combination that came to my mind or I found on stack overflow or other websites, but I am still getting errors. I'll attach the code I feel is the closest one to the correct form.

In following example I have general namespace core (the other ones are called gui, lib and utils). I'm trying to make a Core::LoaderInterface which would be implemented in many ways for different filetypes.

core/loader.h:

#ifndef CORE_LOADER_H
#define CORE_LOADER_H

namespace Core {
    class LoaderInterface;
}

class LoaderInterface
{
    public:
        virtual bool reloadFile();
};

#endif // CORE_LOADER_H

core/lodaer/own.h:

#ifndef CORE_LOADER_OWN_H
#define CORE_LOADER_OWN_H

#include "src/core/loader.h"

namespace Core { namespace Loader {
    class Own;
}}

class Own : public Core::LoaderInterface
{
    public:
        bool reloadFile();
};

#endif // CORE_LOADER_OWN_H

core/loader/own.cpp:

#include "src/core/loader/own.h"

bool Own::reloadFile(){
    return true;
}

Compiler says src/core/loader/own.h:10: error: invalid use of incomplete type ‘class Core::LoaderInterface’ class Own : public Core::LoaderInterface ^

Aucun commentaire:

Enregistrer un commentaire