Expand Minimize
1 out of 32 rated this helpful - Rate this topic

Compiler Error C2062

Error Message

type 'type' unexpected

The compiler did not expect a type name.

The following sample generates C2062:

// C2062.cpp
// compile with: /c
struct A {  : int l; };   // C2062
struct B { private: int l; };   // OK

C2062 can also occur due to the way the compiler handles undefined types in a constructor's parameter list. If the compiler encounters an undefined (misspelled?) type, it assumes the constructor is an expression, and issues C2062. To resolve, only use defined types in a constructor parameter list. The following sample generates C2062:

// C2062_b.cpp
// compile with: /c
class DataSent {};

struct MyDataController {
   MyDataController(int age, DataSet* j) {}   // C2062
   // try the following line instead
   // MyDataController(int age, DataSent* j) {}
};
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.