错误C2059:语法错误'常量' [英] Error C2059: syntax error 'constant'

查看:1891
本文介绍了错误C2059:语法错误'常量'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个头文件如下code:

I have the following code in a header file:

enum {false,true};

和我有我的main.c中的主要功能如果我改变了延伸到的main.cpp
我收到以下错误:

and I have my main function in main.c. if I change the extention to main.cpp I get the following error:

Error C2059: syntax error 'constant' 

即时通讯使用Visual C ++,任何想法why`?

Im using visual c++, any Idea why`?

推荐答案

真正是关键字重新$在C ++ p $ psenting常数值。你不能用它来命名的东西,如枚举值。

true and false are keywords representing constant values in C++. You cannot use them to name things such as enum values.

作为一个例子,下面将汇编

As an example, the following would compile

enum { false_, true_ };

int main() {}

这篇关于错误C2059:语法错误'常量'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆