Microsoft KB Archive/166513: Difference between revisions
From BetaArchive Wiki
(importing KB archive) |
m (Text replacement - ">" to ">") |
||
Line 54: | Line 54: | ||
error C2275: 'test::run' : illegal use of this type as an expression<br /> | error C2275: 'test::run' : illegal use of this type as an expression<br /> | ||
error C2146: syntax error : missing ')' before identifier 'arg'<br /> | error C2146: syntax error : missing ')' before identifier 'arg'<br /> | ||
error C2612: trailing '.*|- | error C2612: trailing '.*|->*' illegal in base/member initializer list<br /> | ||
error C2059: syntax error : ')'<br /> | error C2059: syntax error : ')'<br /> | ||
error C2143: syntax error : missing ';' before '{'<br /> | error C2143: syntax error : missing ';' before '{'<br /> |
Latest revision as of 20:41, 20 July 2020
Article ID: 166513
Article Last Modified on 7/5/2005
APPLIES TO
- Microsoft Visual C++ 4.2 Enterprise Edition
- Microsoft Visual C++ 4.2 Professional Edition
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
This article was previously published under Q166513
SYMPTOMS
Using a typedef cast in the member initialization of a class may cause the following errors:
RESOLUTION
Use the actual type rather then the typedef. For example, in the following sample use test::run rather than test_run. Or, use the functional notation test_run (arg) for type conversion instead of the cast notation. Another option is to initialize the member in the body of function.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was corrected in Microsoft Visual C++ version 6.0.
MORE INFORMATION
/* Compiler Options Needed : none */ class test { public: enum run{ one, two, three }; }; typedef test::run test_run; class test2 { test2(int); ~test2(); public: test_run testvalue; }; test2::test2(int arg):testvalue( (test_run) arg) {} //Causes error // test2::test2(int arg):testvalue( (test::run) arg) {} //WORKAROUND 1 // test2::test2(int arg):testvalue( test_run (arg)) {} //WORKAROUND 2
Keywords: kbbug kbfix kbvc600fix KB166513