FIX: C2371: Cast to Struct Ptr in Default Arg of Class MemberLast reviewed: September 19, 1997Article ID: Q148504 |
The information in this article applies to:
SYMPTOMSWhen encountering a cast to a structure pointer in the default argument of a class member function, the Visual C++ compiler generates the following error:
error C2371: 'MyClass' : redefinition; different basic typesThis error does not occur if the function declaration is not a member of a class.
RESOLUTIONIf you are casting from an integral literal, remove the cast. For example, change this:
MyFunc (struct MyStruct *p = (struct MyStruct*)0); //C2371 errorto this:
MyFunc (struct MyStruct *p = 0); //no errorIf you are casting from a different structure type, remove the struct keyword from the cast. For example, change this:
yFunc (struct MyStruct *p = (struct MyStruct*)x); //C2371 errorto this:
MyFunc (struct MyStruct *p = (MyStruct*)x); //no error STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0. Keywords : CPPIss vcbuglist400 vcfixlist500 kbprg kbtool Version : 4.0 4.1 4.2 Platform : NT WINDOWS Issue type : kbbug Solution Type : kbfix |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |