表 6-1 に、C++ および C の全予約キーワードと、C++ で事前定義されているキーワードを示します。C++ では予約されていて、C では予約されていないキーワードは太字で示しています。
表 6-1 予約キーワード
asm |
do |
if |
return |
typedef |
auto |
double |
inline |
short |
typeid |
bool |
dynamic_cast |
int |
signed |
typename |
break |
else |
long |
sizeof |
union |
case |
enum |
mutable |
static |
unsigned |
catch |
explicit |
namespace |
static_cast |
using |
char |
export |
new |
struct |
virtual |
class |
extern |
operator |
switch |
void |
const |
false |
private |
template |
volatile |
const_cast |
float |
protected |
this |
wchar_t |
continue |
for |
public |
throw |
while |
default |
friend |
register |
true |
|
delete |
goto |
reinterpret_cast |
try |
|
__STDC__ はあらかじめ値 0 に定義されています。たとえば、次のコードがあるとします。
#include <stdio.h> main() { #ifdef _ _STDC_ _ printf("yes¥n"); #else printf("no¥n"); #endif #if _ _STDC_ _ ==0 printf("yes¥n"); #else printf("no¥n"); #endif }
yes yes
次の表は、ISO C++ 標準委員会の現在の ANSI/ISO 検討資料に指定されている、演算子と句読文字の代替表現のための予約語を示したものです。これらの代替表現は現在の C++ コンパイラには実装されていませんが、将来のリリースでは予約語として採用される可能性があるため、他の目的で使用しないでください。
表 6-2 演算子と句読文字に対する予約語
and |
bitor |
not |
or |
xor |
and_eq |
compl |
not_eq |
or_eq |
xor_eq |
bitand |
|
|
|
|