L
Leo
I have a member function in this class, which needs a variable to keep
track its status. Thus I used a static member variable.
But I encounter a "unresolved external variable" error during compile
(for the variable a).
Can anyone tell me what I did wrong?
////////////// testclass.h
#pragma once
class testclass
{
public:
// constructor and destructor
testclass(void);
~testclass(void);
// static part
static int a;
static void test(void);
};
////////////// testclass.cpp
#include "testclass.h"
testclass::testclass(void)
{
}
testclass::~testclass(void)
{
}
void testclass::test(void)
{
// problem appears after I put this line
a=1;
}
track its status. Thus I used a static member variable.
But I encounter a "unresolved external variable" error during compile
(for the variable a).
Can anyone tell me what I did wrong?
////////////// testclass.h
#pragma once
class testclass
{
public:
// constructor and destructor
testclass(void);
~testclass(void);
// static part
static int a;
static void test(void);
};
////////////// testclass.cpp
#include "testclass.h"
testclass::testclass(void)
{
}
testclass::~testclass(void)
{
}
void testclass::test(void)
{
// problem appears after I put this line
a=1;
}