When I declare a static data member (i.e. a class variable), I get a link
error...

The sample code below leads to the following error messages :

Link Error : main.cpp: 'Test::shared' referenced from 'Test::SetShared(int)'
is undefined.
Link Error : main.cpp: 'Test::shared' referenced from 'Test::GetShared()' is
undefined.


The same code works fine with GCC.
Any idea ?

---------------------------------------
class Test {
    private :
        static int shared;
    public :
        void SetShared(int n);
        int GetShared(void);
};

void Test::SetShared(int n)
{
    shared = n;
}

int Test::GetShared(void)
{
    return shared;
}

...

Test test;
int n;

test.SetShared(12);
n = test.GetShared();
---------------------------------------

-- Denis Faivre - [EMAIL PROTECTED]
-- Ablivio - http://www.ablivio.com



Reply via email to