John Gaughan | 1 Jul 2004 15:45
Gravatar

Re: [mingw - C/C++] Why undefined reference?

SourceForge.net said:
> By: nioannou
>
> I try to compile the following code, but during linking I get an
> "undefined
> reference to A::a" error. Does anyone know why?

Try initializing your static variable. For example, put this outside your
class declaration:

int A::a = 0;

I do not remember why this is the way it is, but this change fixes it. I
do not have my copy of the standard available where I am at or I would
explain it better.

--

-- 
John Gaughan
john@...
http://www.johngaughan.net/

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users


Gmane