Article ID: 135536
Article Last Modified on 10/24/2003
/* Compile options needed: None (compiler defaults will do)
*/
struct A {
// A() {} // ctor added for explicit initialization
void some_funct(){}
};
template <class T> struct B {
static A static_member;
void func() { static_member.some_funct(); }
};
// error will occur on the following line:
template <class T> A B<T>::static_member /* = A() */ ;
void main()
{
B<int> b;
b.func();
}
This code, as shown, generates the error. To work around the problem,
change the line where A() is declared and defined from a comment into an
executed line, and do the same for the = A() on the line where the error is
occurring. This explicitly initializes the data member when it is declared.
Additional query words: 2.00 2.10 2.20 9.0 9.00 9.1 9.10 visualc VC cl
Keywords: kbbug kbfix kblangcpp kbarttypeinf KB135536