[编译记录]关于编译器错误C2885...
来源:互联网 发布:我们相遇网络歌词 编辑:程序博客网 时间:2024/05/20 02:27
namespace ai {
namespace rbs {
using RuleBasedSystemBase::Rule;
using RuleBasedSystemBase::Rule;
class RuleBasedSystemInterface{};
}
}
}
C2885编译错误....VC8中似乎一定要把using声明放在类内。
把using 写到类内就可以了...
class RuleBasedSystemInterface
{
public:
};
}
}
}
以下为MSDN上的说明...
Visual C++ 概念: 建置 C/C++ 程式
錯誤訊息
'class::identifier': 在非類別範圍不是有效的 using 宣告using 宣告的使用不正確。
範例
對 Visual C++ 2005 完成一致性處理後可能會產生這項錯誤:讓 using 宣告至巢狀型別已不再有效;您必須明確限定至巢狀型別的各個參考,將型別置於命名空間中,或是建立 typedef。如需詳細資訊,請參閱 Breaking Changes in the Visual C++ 2005 Compiler。
下列範例會產生 C2885。
// C2885.cpp
namespace MyNamespace {
class X1 {};
}
struct MyStruct {
struct X1 {
int i;
};
};
int main () {
using MyStruct::X1; // C2885
// OK
using MyNamespace::X1;
X1 myX1;
MyStruct::X1 X12;
typedef MyStruct::X1 abc;
abc X13;
X13.i = 9;
}
如果您將 using 關鍵字和類別成員一起使用,則 C++ 會要求您在另一個類別 (衍生類別) 之中定義該成員。
下列範例會產生 C2885。
// C2885_b.cpp
// compile with: /c
class A {
public:
int i;
};
void z() {
using A::i; // C2885 not in a class
}
class B : public A {
public:
using A::i;
};
引用MSDN改变说明...
5. A using declaration of nested type is now illegal
Affected User Scenario:
Customers that have a using declaration with a nested type will now get C2885.
Description:
Before users where allowed to bring in a nested type's declaration to global scope by a using declaration. This is not allowed in Standard C++.
Customer Workaround:
Customer workaround is to fully qualify his nested type whenever he wants to use it. A typedef can also be used to bypass using the scope resolution operator everywhere.
Rationale:
The using declaration cannot be used with nested classes, the C++ Standard specifies that it can be used to bring a class into the scope that is contained in a namespace, not a class.
- [编译记录]关于编译器错误C2885...
- php 编译错误记录
- 编译错误记录
- ISE编译错误记录
- studio 编译错误记录
- 系统编译错误记录
- GDAL编译错误记录
- AS 编译错误记录
- Caffe 编译错误记录
- 交叉编译器及常见编译错误
- 交叉编译器及常见编译错误
- nc studio编译器编译大量错误问题解决
- 关于vs编译器Lnk2005错误的随感
- 关于C++编译错误
- 关于R_ARM_CALL编译错误
- linux内核编译错误记录
- linux内核编译错误记录
- Android4.0编译错误记录
- 泛型类/泛型委托示例
- 倪光南院士:现在年轻人不够踏实
- 内联函数与外联函数的区别
- 推荐几个Java开发者应该多去的技术网站
- linq学习笔记(一)
- [编译记录]关于编译器错误C2885...
- 二月西班牙亮相 GARMIN推出首款3G touch screen GPS手机
- 世界编程语言排行榜08年01月_VB 语言
- CreateThread和_beginthread的区别
- const用法小结(转)
- 世界编程语言排行榜08年01月_PHP 语言
- 关于项目管理的知识点
- 定义类
- 最初级的堆栈溢出分析问题