The information in this article applies to:
SYMPTOMSIf an object is used to initialize an embedded structure, the compiler produces error C2440: 'initializing': cannot convert from '<type1> ' to '<type2> '. CAUSEThis behavior is by design. Although an aggregate that is a class may be initialized with an object of its class, there is not a similar provision for subaggregates. RESOLUTIONTo work around this behavior, use a member by member initialization. MORE INFORMATIONThe following sample code demonstrates this problem and its resolution. The error produced in the initialization of two2 is error C2440: 'initializing' : cannot convert from 'struct ::One ' to 'int '. Sample Code
Additional query words: 8.00 8.00c 9.00 10.00 11.00
Keywords : kbCompiler kbCPPonly kbVC kbVC100 kbVC150 kbVC200 kbVC400 kbVC410 kbVC420 kbVC500 kbVC600 |
Last Reviewed: September 16, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |