0

I have the following classA.h

#ifndef ClassAH
#define ClassAH
class A
{
public :
      A();
     ~A();
      static std::map< std::string, std::vector< string > > getSomething();
}
#endif

and the implementation in classA.cpp

#include classA.h

std::map< std::string, std::vetor< string > > classA::getSomething()
{
   //implementation

   return map
}

Now I have another class classB.cpp in which I am doing :

#include classA.h
void method1()
{
   std::map< std::string, std::vector< string > > map = classA::getSomething();
}

Note getSomething() is static.

when I compile classB I am getting error LNK2019 on the method getSomething() saying unresolved external symbol ....referenced in method1().

What's going wrong here?

SomeDude
  • 13,876
  • 5
  • 21
  • 44

1 Answers1

0

in classA.cpp you just declared global function. You must include A:: in definition:

std::map< std::string, std::vector< string > > A::getSomething() 
{
    return map;
}

This way compiler knows that method getSomething() belongs to the class A

Rafal Mielniczuk
  • 1,322
  • 7
  • 11