编译器错误 C2653 |
错误消息
“identifier”: 不是类或命名空间名称语法需要类、结构、联合或命名空间名称。
下面的示例生成 C2653:
// C2653.cpp // compile with: /c class yy { void func1(int i); }; void xx::func1(int m) {} // C2653 void yy::func1(int m) {} // OK |
如果尝试定义复合命名空间,也可能会发生 C2653;C++ 中不允许复合命名空间:
// C2653b.cpp namespace a::b {int i;} // C2653 namespace a { namespace b { int i; } } int main() { a::b::i = 2; } |
避免头文件重复引用
//#pragma once
#ifndef _xxx_H
#define _xxx_H
#ifndef _xxx_H
#define _xxx_H
Class{};
#endif
用#ifndef _xxx_H #define _xxx_H 。。。#endif的时候 ifndef少个“n”也会造成则个错误 记录下