c++ - What is the meaning of "qualifier"? -
c++ - What is the meaning of "qualifier"? -
what meaning of "qualifier" , difference between "qualifier" , "keyword"?
for volatile
qualifier in c , can volatile
keyword, meaning of "qualifier"?
a qualifier adds "quality", such specifying volatility or constness of variable. they're similar adjectives: "a fickle man", "a volatile int", "an incorruptible lady", "a const double". or without qualifier, variable still occupies same amount of memory, , each bit has same interpretation or contribution state/value. qualifiers specify how may accessed or stored.
keywords predefined reserved identifiers (arguably, see below) language assigns meaning to, rather leaving free utilize own purposes (i.e. naming variables, types, namespaces, functions...).
examplesvolatile
, const
both qualifiers , keywords if
, class
, namespace
keywords not qualifiers std
, main
, iostream
, x
, my_counter
identifiers neither keywords nor qualifiers there's total list of keywords @ http://www.cppreference.com/wiki/keywords/start. c++ doesn't have qualifiers aren't keywords (i.e. they're "words" rather punctuation symbols).
where qualifiers appear relative other type information?a quick aside "what qualifier mean" syntax of using qualifier - zaibis comments below:
...[qualifiers] qualify follows [when] there nil preceding. if want const
pointer non-const
object had write char * const var
...
a bit (lot?) identifiers
identifiers lexical tokens (distinct parts of c++ source code) that:
begin alpha/letter character or underscore continue 0 or more alphanumerics or underscoresif helps, can think of identifiers specified regexp "[a-za-z_][a-za-z_0-9]*". examples "egg", "string", "__f", "x0" not "4e4" (a double
literal), "0x0a" (that's hex literal), "(f)" (that's 3 lexical tokens, middle beingness identifier "f").
but keywords identifiers?
for c++, terminology isn't used consistently. in general computing usage, keywords subset of identifiers, , places/uses in c++11 standard reflect that:
"the identifiers shown in table 4 reserved utilize keywords" (first sentence in 2.12 keywords) "identifiers keywords or operators in c++..." (from 17.6.1.2 footnote 7)(there alternative forms of operators - not
, and
, xor
, or
- though annoyingly visual c++ disables them default avoid breaking old code used them not operators.)
as potatoswatter points out in comment, in many other places standard defines lexical tokens identifier
, keyword
mutually exclusive tokens in grammar:
there's border case determination's context sensitive:
if keyword (2.12) or alternative token (2.6) satisfies syntactic requirements of identifier (2.11) contained in attribute-token, considered identifier. (7.6.1. attribute syntax , semantics 2) non-keyword identifiers still shouldn't usesome identifiers, "std" or "string", have specific usage specified in c++ standard - not keywords though. generally, compiler doesn't treat them differently own code, , if don't include standard-specified headers compiler won't know standard-mandated utilize of "std". might able create own function, variable or type called "std". not thought though... while it's nice understand general partition between keywords , standard library, implementations have freedom blur boundaries should assume c++ features work when relevant headers included , usage matches documentation, , not might conflict.
c++ c
Comments
Post a Comment