Click here to Skip to main content
16,008,183 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCFileFind question (Idiot) Pin
Michael Martin11-Jul-01 4:46
professionalMichael Martin11-Jul-01 4:46 
GeneralRe: CFileFind question (Idiot) Pin
11-Jul-01 5:24
suss11-Jul-01 5:24 
GeneralRe: CFileFind question (Idiot) Pin
Michael Martin11-Jul-01 14:47
professionalMichael Martin11-Jul-01 14:47 
GeneralRe: CFileFind question (Idiot) Pin
Malcolm McMahon13-Jul-01 2:43
Malcolm McMahon13-Jul-01 2:43 
QuestionHow to delete a directory Pin
Djibril11-Jul-01 3:46
professionalDjibril11-Jul-01 3:46 
GeneralSystem modal box when the app crashes Pin
GregT11-Jul-01 2:54
GregT11-Jul-01 2:54 
GeneralRe: System modal box when the app crashes Pin
Tomasz Sowinski11-Jul-01 3:08
Tomasz Sowinski11-Jul-01 3:08 
GeneralStatic members/methods (Beginner) Pin
Jimmy Ehrnström11-Jul-01 1:40
Jimmy Ehrnström11-Jul-01 1:40 
Hi!

Maybe somebody could help me out by pointing out what's wrong with the following code:

#include <iostream.h>

class CResult
{
public:
static void SetFoo(int);
static int GetFoo();

private:
static int foo;
};

void CResult::SetFoo(int f)
{
foo = f;
}

int CResult::GetFoo()
{
return(foo);
}

int main(int argc, char* argv[])
{
CResult::SetFoo(17);
cout << CResult::GetFoo();
return(0);
}

At the linking stage of the compilation (VC++ 6.0) I get the following error:

Result.obj : error LNK2001: unresolved external symbol "private: static int CResult::foo" (?foo@CResult@@0HA)
Static___Win32_Debug/Static.exe : fatal error LNK1120: 1 unresolved externals

Since I'm far from experienced in C++/VC++ I can't figure out how to get the above sample to work. I've probably misunderstood how static members/methods work, so any help would be greatly appreciated.

Thanks,

Jimmy
GeneralRe: Static members/methods (Beginner) Pin
Tomasz Sowinski11-Jul-01 1:54
Tomasz Sowinski11-Jul-01 1:54 
GeneralRe: Static members/methods (Beginner) Pin
Tomasz Sowinski11-Jul-01 1:58
Tomasz Sowinski11-Jul-01 1:58 
GeneralRe: Static members/methods (Beginner) Pin
Jimmy Ehrnström11-Jul-01 2:13
Jimmy Ehrnström11-Jul-01 2:13 
GeneralEnumerating messages Pin
Gennady Oster11-Jul-01 1:15
Gennady Oster11-Jul-01 1:15 
GeneralRe: Enumerating messages Pin
Tomasz Sowinski11-Jul-01 1:46
Tomasz Sowinski11-Jul-01 1:46 
GeneralRe: Enumerating messages Pin
Gennady Oster11-Jul-01 2:03
Gennady Oster11-Jul-01 2:03 
GeneralRe: Enumerating messages Pin
Tomasz Sowinski11-Jul-01 2:12
Tomasz Sowinski11-Jul-01 2:12 
GeneralRe: Enumerating messages Pin
Gennady Oster11-Jul-01 2:29
Gennady Oster11-Jul-01 2:29 
GeneralRe: Enumerating messages Pin
Tomasz Sowinski11-Jul-01 2:42
Tomasz Sowinski11-Jul-01 2:42 
Questionmouse over ?? Pin
Pony10-Jul-01 21:19
Pony10-Jul-01 21:19 
GeneralDebugging Question (Beginner) Pin
matthias s.10-Jul-01 20:34
matthias s.10-Jul-01 20:34 
GeneralRe: Debugging Question (Beginner) Pin
Tim Deveaux11-Jul-01 8:35
Tim Deveaux11-Jul-01 8:35 
GeneralRe: Debugging Question (Beginner) Pin
8-Aug-01 21:53
suss8-Aug-01 21:53 
GeneralTracing Splitter Pin
10-Jul-01 19:56
suss10-Jul-01 19:56 
GeneralRe: Tracing Splitter Pin
coder847210-Jul-01 21:16
coder847210-Jul-01 21:16 
GeneralPhotoShop SDK Pin
HyoSoo Moon10-Jul-01 19:08
HyoSoo Moon10-Jul-01 19:08 
GeneralSQL (.Jet) useage Pin
otvac10-Jul-01 16:45
otvac10-Jul-01 16:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.