[编译记录]关于编译器错误C2885...
2008-02-02 23:21
344 查看
namespace fear {
namespace ai {
namespace rbs {
using RuleBasedSystemBase::Rule;
using RuleBasedSystemBase::Rule;
class RuleBasedSystemInterface{};
}
}
}
C2885编译错误....VC8中似乎一定要把using声明放在类内。
把using 写到类内就可以了...
class RuleBasedSystemInterface
{
public:
};
}
}
}
以下为MSDN上的说明...
Visual C++ 概念: 建置 C/C++ 程式
編譯器錯誤 C2885
using 宣告的使用不正確。
下列範例會產生 C2885。
如果您將 using 關鍵字和類別成員一起使用,則 C++ 會要求您在另一個類別 (衍生類別) 之中定義該成員。
下列範例會產生 C2885。
引用MSDN改变说明...
namespace ai {
namespace rbs {
using RuleBasedSystemBase::Rule;
using RuleBasedSystemBase::Rule;
class RuleBasedSystemInterface{};
}
}
}
C2885编译错误....VC8中似乎一定要把using声明放在类内。
把using 写到类内就可以了...
class RuleBasedSystemInterface
{
public:
};
}
}
}
以下为MSDN上的说明...
Visual C++ 概念: 建置 C/C++ 程式
編譯器錯誤 C2885
錯誤訊息
'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.相关文章推荐
- 关于Visual Studio 2013 编译 multi-byte character set MFC程序出现 MSB8031 错误的解决办法
- 关于VC6.0++中以及VS2008中编译出现的LINK错误
- 关于nfs的配置与错误记录
- 记录几个C++多继承中,this指针与多虚表间编译与处理的疑问,看编译器的行为。
- 关于网上流传的nginx文档的1个错误(nginx+tomcat日志记录真实IP)
- IOS开发过程中Xcode编译错误以及运行时异常等问题记录
- 关于wince 使用占用空间大的内存变量问题(编译无错误但是无法运行的问题)
- 关于:Update后引发 并发冲突:DeleteCommand 影响 0 个记录 的错误
- DJYOS嵌入式编译常遇到的编译错误记录
- 关于VC编译错误fatal error C1083的解决办法
- VC中关于编译时候的错误提示:is not a precompiled header
- 创建ROS工作空间使用catkin_make时出现和python编译器有关的编译错误
- Ubuntu16.04+cuda9.0+opencv3.1+matlab2016a+anaconda+caffe(C3D)+编译过程错误记录
- 关于Android Studio中点9图的编译错误问题:Some file crunching failed
- 关于Linux下C编译错误(警告)cast from 'void*' to 'int' loses precision
- 关于VS2013 项目编译时,出现C1083的错误
- 关于include<vector>编译错误问题
- 关于qt中使用ico文件做程序图标时编译报debug/myico_res.o Error 1错误的说明
- 关于PAC Fetch failed with cached error 错误的记录
- 关于mini2440/micro2440下的Qtopia编译错误解答 - 上海嵌入式家园 贺工