BUG: C2440 Expanding Template with a Pointer to a Nested ClassLast reviewed: July 31, 1997Article ID: Q149327 |
The information in this article applies to:
SYMPTOMSAt the point where a class template is expanded using a pointer to a nested class, the compiler reports the following errors (generated by the sample code listed in this article):
[FileName](14) : error C2440: 'initializing' : cannot convert from 'class A::B' to 'class A::B *' (new behavior; please see help) [FileName](14) : error C2439: 't' : member could not be initializedLines 13 and 14 in the sample code are:
template <class T> C<T>::C() : t(T()) // error { RESOLUTIONThere are three possible workarounds to this problem. Each is stated here in terms of the sample code included in this article:
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 INFORMATIONIn this case, the problem is caused by the attempt to initialize the data member t.
Sample Code
/* Compile options needed: None */ template <class T> class C { public: C(); private: T t; }; template <class T> C<T>::C() : t(T()) // error { } class A { public: class B { }; }; main() { C<A::B *> c; return 0; } Keywords : CLIss vcbuglist400 vcbuglist500 kbprg Version : 4.0 4.1 4.2 5.0 Platform : NT WINDOWS Issue type : kbbug |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |