網路城邦
上一篇 回創作列表 下一篇   字體:
C語言的一些關鍵字與變數
2009/09/03 17:45:05瀏覽1472|回應0|推薦6
在C語言中,變數名稱由我們自取,但有規定需要遵守:
  1. 第一個字母必須是英文字或是"_"底線符號
  2. 其它字母必須是英文字、數字或"_"底線符號
  3. 不可以使用 C++ 關鍵字 ( 保留字 )
  4. 大小寫是有區別的

※關鍵字
下表為 C++ 關鍵字,這些關鍵字都不可以被用來當做常數或變數
KeywordDescription
asminsert an assembly instruction
autodeclare a local variable
booldeclare a boolean variable
breakbreak out of a loop
casea block of code in a switch statement
catchhandles exceptions from throw
chardeclare a character variable
classdeclare a class
constdeclare immutable data or functions that do not change data
const_castcast from const variables
continuebypass iterations of a loop
defaultdefault handler in a case statement
deletemake dynamic memory available
dolooping construct
doubledeclare a double precision floating-point variable
dynamic_castperform runtime casts
elsealternate case for an if statement
enumcreate enumeration types
explicitonly use constructors when they exactly match
exportallows template definitions to be separated from their declarations
externtell the compiler about variables defined elsewhere
falsea constant representing the boolean false value
floatdeclare a floating-point variable
forlooping construct
friendgrant non-member function access to private data
gotojump to a different part of the program
ifexecute code based on the result of a test
inlineoptimize calls to short functions
intdeclare an integer variable
longdeclare a long integer variable
mutableoverride a const variable
namespacepartition the global namespace by defining a scope
newallocate dynamic memory for a new variable
operatorcreate overloaded operator functions
privatedeclare private members of a class
protecteddeclare protected members of a class
publicdeclare public members of a class
registerrequest that a variable be optimized for speed
reinterpret_castchange the type of a variable
returnreturn from a function
shortdeclare a short integer variable
signedmodify variable type declarations
sizeofreturn the size of a variable or type
staticcreate permanent storage for a variable
static_castperform a nonpolymorphic cast
structdefine a new structure
switchexecute code based on different possible values for a variable
templatecreate generic functions
thisa pointer to the current object
throwthrows an exception
truea constant representing the boolean true value
tryexecute code that can throw an exception
typedefcreate a new type name from an existing type
typeiddescribes an object
typenamedeclare a class or undefined type
uniona structure that assigns multiple variables to the same memory location
unsigneddeclare an unsigned integer variable
usingimport complete or partial namespaces into the current scope
virtualcreate a function that can be overridden by a derived class
voiddeclare functions or data with no associated data type
volatilewarn the compiler about variables that can be modified unexpectedly
wchar_tdeclare a wide-character variable
whilelooping construct

( 心情隨筆心情日記 )
回應 推薦文章 列印 加入我的文摘
上一篇 回創作列表 下一篇

引用
引用網址:https://classic-blog.udn.com/article/trackback.jsp?uid=hanfred&aid=3284635