共用方式為


C++ Keywords

Keywords are predefined reserved identifiers that have special meanings. They cannot be used as identifiers in your program. The following keywords are reserved for Microsoft C++. Names with leading underscores are Microsoft extensions.

__abstract 2

__alignof Operator

__asm

__assume

__based

__box 2

__cdecl

__declspec

__delegate2

__event

__except

__fastcall

__finally

__forceinline

__gc 2

__hook 3

__identifier

__if_exists

__if_not_exists

__inline

__int16

__int32

__int64

__int8

__interface

__leave

__m128

__m128d

__m128i

__m64

__multiple_inheritance

__nogc 2

__noop

__pin 2

__property 2

__raise

__sealed 2

__single_inheritance

__stdcall

__super

__thiscall

__try/__except, __try/__finally

__try_cast 2

__unaligned

__unhook 3

__uuidof

__value 2

__virtual_inheritance

__w64

__wchar_t, wchar_t

abstract

array

auto

bool

break

case

catch

char

class

const

const_cast

continue

decltype

default

delegate

delete

deprecated1

dllexport1

dllimport1

do

double

dynamic_cast

else

enum

enum class

enum struct

event

explicit

extern

false

finally

float

for

for each, in

friend

friend_as

gcnew

generic

goto

if

initonly

inline

int

interface class

interface struct

interior_ptr

literal

long

mutable

naked1

namespace

new

new

noinline1

noreturn1

nothrow1

novtable1

nullptr

operator

private

property

property1

protected

public

ref class

ref struct

register

reinterpret_cast

return

safecast

sealed

selectany1

short

signed

sizeof

static

static_assert

static_cast

struct

switch

template

this

thread1

throw

true

try

typedef

typeid

typeid

typename

union

unsigned

using declaration, using directive

uuid1

value class

value struct

virtual

void

volatile

while

1   Extended attributes for the __declspec keyword.

2   Applicable to Managed Extensions for C++ only. This syntax is now deprecated.

3   Intrinsic function used in event handling.

See Component Extensions for Runtime Platforms for more information.

Microsoft Specific

In Microsoft C++, identifiers with two leading underscores are reserved for compiler implementations. Therefore, the Microsoft convention is to precede Microsoft-specific keywords with double underscores. These words cannot be used as identifier names.

Microsoft extensions are enabled by default. To ensure that your programs are fully portable, you can disable Microsoft extensions by specifying the ANSI-compatible /Za command-line option (compile for ANSI compatibility) during compilation. When you do this, Microsoft-specific keywords are disabled.

When Microsoft extensions are enabled, you can use the Microsoft-specific keywords in your programs. For ANSI compliance, these keywords are prefaced by a double underscore. For backward compatibility, single-underscore versions of all the double-underscored keywords except __except, __finally, __leave, and __try are supported. In addition, __cdecl is available with no leading underscore.

The __asm keyword replaces C++ asm syntax. asm is reserved for compatibility with other C++ implementations, but not implemented. Use __asm.

The __based keyword has limited uses for 32-bit and 64-bit target compilations.

See Also

Reference

Lexical Conventions

C++ Operators