0

1) D:\imp\msgList\fun1.cpp

CMLMessage::MLMessageStatus CMLMessage::getInformationBlocks(const TBase::TLocale& fallbackLocale )
  {
     CDatabaseHelper::setfallBackLocale(fallbackLocale); // setter function
  }

2) D:\imp\commonfolder\fun2.cpp

class CDatabaseHelper
{
  Public:
         static void setfallBackLocale(TBase::TLocale fallbackLocale)
          { 
            mfallbackLocale = fallbackLocale;
           }
  Private:
           static TBase::TLocale mfallbackLocale; // class member 
}

Compiler giving Error:

error LNK2001: unresolved external symbol "private: static struct TBase::TLocale NTrafficInformation::CDatabaseHelper::mfallbackLocale" (?mfallbackLocale@CDatabaseHelper@NTrafficInformation@@0UTLocale@TBase@@A)

Hi experts Do you have any suggestion for this?

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60

1 Answers1

0

In fun2.cpp, you need to initialize that static member with something like:

TBase::TLocale CDatabaseHelper::mfallbackLocale = TBase::TLocale{"C"};  

where the right-hand side is any valid expression producing a TLocale. This line should go after the class definition.

See the cppreference page on "static members" for alternative ways to declare/define that static member.

NicholasM
  • 4,557
  • 1
  • 20
  • 47
  • Certainly. If this has helped, take a look at this topic in the Help Center: [What should I do when someone answers my question](https://stackoverflow.com/help/someone-answers) – NicholasM Feb 02 '20 at 22:12