Compiler Error C2071

今天在编程时遇到这个错误

错误提示:error c2071::illegal storage class

然后在msdn上查了下:

Compiler Error C2071

Error Message

‘identifier’ : illegal storage class
_ identifier _ was declared with an invalid storage class.

Example

The following sample generates C2071.

[ ![](http://i.msdn.microsoft.com/Platform/Controls/CodeSnippet/resources/copy
_off.gif) Copy Code
](javascript:CopyCode(‘ctl00_rs1_mainContentContainer_ctl01other’)😉

// C2071.cpp
// compile with: /c
struct C {
   extern int i;   // C2071
};
struct D {
   int i;   // OK
};

The following sample generates C2071.

[ ![](http://i.msdn.microsoft.com/Platform/Controls/CodeSnippet/resources/copy
_off.gif) Copy Code
](javascript:CopyCode(‘ctl00_rs1_mainContentContainer_ctl02other’)😉

// C2071_b.cpp
// compile with: /c
typedef int x(int i) { return i; }   // C2071
typedef int x;   // OK
发现原来是错用了那些关键字。
后来检查了一下,发现是explicit使用错误。
我将operator=()重载使用了explicit关键字。所以去掉后程序编译通过。