C++保留字

来源:互联网 发布:sql password 编辑:程序博客网 时间:2024/06/06 00:41

先上ANSI C规定的C++保留字

auto
break
case
char
char
const
continuedefault
double
else
enum
extern
float
forgoto
if
int
long
register
return
shortsigned
sizeof
static
struct
switch
typedef
unionunsigned
void
volatile
while

在VS2008中调试通过。提交到USACO竟然是编译错误!

仔细检查,最后将嫌疑锁定在叫xor的变量上。改掉变量名,一切正常~

我们都知道,C++中异或运算的运算符是^,ANSI国际标准也没有规定xor这个保留字。但是,各种编译器(如USACO用的GCC)因平台原因,通常会添加一些自己的保留字。xor应该就是其一。

为了避免这种问题,我找到另一张列表,这里是扩充过的C++保留字,尽管一些在国际标准中没有,但作为一种编程习惯,我们应避免将它们作为自己的标识符。

and                                  and_eq                          asm                                auto
bitand                              bitor                              bool                                break
case                                catch                              char                                class
compl                              const                             const_cast                      continue
default                            delete                              do                                 double
dynamic_cast                  else                                 enum                             explicit
export                            extern                             false                               float
for                                 friend                               goto                              if
inline                              int                                   long                               mutable
namespace                      new                                not                                 not_eq
operator                         or                                  or_eq                               private
protected                        public                             register                           signed
reinterpret_cast               return                            short                              struct
sizeof                             static                              static_cast                      throw
switch                            template                         this                                 typeid
true                               try                                 typedef                            using
typename                       union                              unsigned                         wchar_t
virtual                             void                              volatile                              while
xor                               xor_eq


原创粉丝点击