Using g++ 7.3.0.
I have a global data structure (spaceA::bars) that is used throughout my program. I am trying to pass SharedBarMap into class Foo which will operate on the data in bars.
The problem is, the namespace doesn't appear to be seen within class Foo.
error: 'spaceA' has not been declared
spaceA::SharedBarMap sbm;
~~~~~~
globals.h
namespace spaceA
{
using MapGroup = std::vector<std::shared_ptr<Bars>>;
using BarMap = std::map<int, MapGroup>;
using SharedBarMap = std::shared_ptr<BarMap>;
extern SharedBarMap bars;
}
globals.cpp
namespace spaceA
{
SharedBarMap bars;
}
foo.h
#include "globals.h"
class Foo
{
private:
spaceA::SharedBarMap sbm; // <--- error here
public:
Foo(spaceA::SharedBarMap bars) : sbm(bars) { }
};
Aucun commentaire:
Enregistrer un commentaire