lundi 17 avril 2017

LNK Error with using nested classes

I'm getting a LNK error whenever I'm using a function from my nested class called by the singleton of my main class... I have searched around but none of the answers on MSDN apply to my issue regarding fixing this lnkerror.

//MainClass.hpp
class MainClass
{
public:
   static MainClass& get(); //singleton
private:
   MainClass();
public:
   class NestedClass
   {
   public:
      NestedClass();
   public:
      void some_function();
   };
public:
   std::vector<NestedClass> get_nested_array();
private:
   std::vector<NestedClass> array_of_nested; //gets filled in MainClass ctor
};

//SomeClass.cpp
SomeClass::SomeClass()
{
   auto nesteds = MainClass::get().get_nested_array();
   for(auto& n : nesteds) {
        n.some_function(); //throws LNKError 2019 in MSVC
   }
}

Aucun commentaire:

Enregistrer un commentaire