Discussion:
static member
(too old to reply)
Carl Forsman
2009-08-21 22:07:29 UTC
Permalink
why when i defined a static member i got the following error?

===================================

1>Generating Code...
1>Linking...
1>MusicDemo.obj : error LNK2001: unresolved external symbol "public:
static class midi::CMIDIOutDevice CMusicDemo::m_OutDevice"
(?***@CMusicDemo@@***@midi@@A)
1>F:\Remote\Remote\RemoteDemo\app\LifeHubDemo\\..\..\build\LifeHubDemo\LifeHubDemo.exe
: fatal error LNK1120: 1 unresolved externals

===================================

class CMusicDemo
: public Group
{
static midi::CMIDIOutDevice m_OutDevice;
};
Igor Tandetnik
2009-08-21 22:16:15 UTC
Permalink
Post by Carl Forsman
why when i defined a static member i got the following error?
===================================
1>Generating Code...
1>Linking...
static class midi::CMIDIOutDevice CMusicDemo::m_OutDevice"
1>F:\Remote\Remote\RemoteDemo\app\LifeHubDemo\\..\..\build\LifeHubDemo\LifeHubDemo.exe
Post by Carl Forsman
fatal error LNK1120: 1 unresolved externals
You haven't defined it - you've only declared it.
Post by Carl Forsman
class CMusicDemo : public Group
{
static midi::CMIDIOutDevice m_OutDevice;
};
That goes in a header file. Now, in one source file, add this line:

midi::CMIDIOutDevice CMusicDemo::m_OutDevice;

That would be the definition.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Continue reading on narkive:
Loading...