Reputation:
So to declare a static member of a class, a definition of that member is required in a .cpp file to avoid an unresolved external linker error. My problem is that my static member requires the definition of a private struct which won't be available to my static member in the .cpp file.
//foo.h
class A
{
public:
...
private:
struct B
{
...
};
class C
{
public:
...
private:
static std::vector<std::shared_ptr<B>> someVector;
} D;
};
Upvotes: 0
Views: 56
Reputation: 8313
You should declare the vector in the cpp file like this:
std::vector<std::shared_ptr<A::B>> A::C::someVector;
struct B
is unknown outside class A
so it must be reffered on the global scope as A::B
Upvotes: 3