本文介绍了class A {static const int b = 1; };的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我读过Thinking in C ++这段代码有效: --------- A级 { static const int b = 1; }; --------- 但它不是! 我做错了什么? 我使用VC ++ 6并返回: ------- 错误C2258:非法纯语法,必须为''= 0'' 错误C2252:''b'':纯指示符只能为函数指定 - ------ 解决方案 编号VC6是非这个问题的标准。通常的解决方案是enum-as-const " idiom"。就这样做: A级 { enum {b = 1; }; }; - WW又名阿提拉 " WW" < WO *** @ freemail.hu>写道... enum-as-constidiom。就这样做: A级 {枚举{b = 1; }; enum {b = 1}; }; Victor enum {b = 1}; "实际的眼球,躺在e ^ ^ H ^ H ^ H ^ H ^ HBazarov'的头骨,按我们的标准来说是巨大的b / b,占据了比大脑本身更多的空间! http://amos.indiana.edu/library/scripts/eagle.html 问候, 亚历山大。 I read in "Thinking in C++" this code works:---------class A{static const int b = 1;};---------but it doesn''t!I do something wrong?I use VC++6 and it returns:-------error C2258: illegal pure syntax, must be ''= 0''error C2252: ''b'' : pure specifier can only be specified for functions------- 解决方案No. VC6 is non-standard in this matter. The usual fix is the enum-as-const"idiom". Just do it like this:class A{enum { b = 1; };};--WW aka Attilaenum-as-const "idiom". Just do it like this: class A { enum { b = 1; };enum { b = 1 }; };Victor enum { b = 1 };"The actual eyeballs, lying within an ea^H^H^H^H^HBazarov''s skull, arehuge by our standards, taking up more room than the brain itself!" http://amos.indiana.edu/library/scripts/eagle.htmlregards,alexander. 这篇关于class A {static const int b = 1; };的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 13:30