BUG: LNK2001 Error for Static Member in Class TemplateLast reviewed: July 24, 1997Article ID: Q151167 |
The information in this article applies to:
SYMPTOMSLinker error LNK2001 is generated for static member variables of nested classes in class templates. The message states:
error LNK2001: unresolved external symbol "public: static int Outer<int>::Inner::sobj"(?sobj@Inner@?$Outer@H@@2HA) RESOLUTIONDo not use static member variables in nested classes of class templates.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe sample code below gives the error message LNK2001.
Sample Code
/* Compile options needed: none */ template<class T> class Outer { public: static T souter; class Inner { public: static T sobj; }; }; template <class T> double Outer<double>::souter = 1; template <class T> int Outer<int>::Inner::sobj = 5; void main() { double dval = Outer<double>::souter; int i = Outer<int>::Inner::sobj; } |
Keywords : CPPIss vcbuglist400 vcbuglist500
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |