RAD Studio |  |

Primary Expression Operators

For ANSI C, the primary expressions are literal (also sometimes referred to as constant), identifier, and ( expression ). The C++ language extends this list of primary expressions to include the keyword this, scope resolution operator ::, name, and the class destructor ~ (tilde).

The primary expressions are summarized in the following list.

primary-expression:

1. literal this (C++ specific)
2. :: identifier (C++ specific)
3. :: operator-function-name (C++ specific)
4. :: qualified-name (C++ specific)
5. ( expression) name

literal:

1. integer-constantcharacter-constant
2. floating-constant
3. string-literal

name:

1. identifieroperator-function-name (C++ specific)
2. conversion-function-name (C++ specific)
3. ~ class-name (C++ specific)
4. qualified-name (C++ specific)

qualified-name: (C++ specific)

qualified-class-name :: name

For a discussion of the primary expression this, see this (keyword). The keyword this cannot be used outside a class member function body.

The discussion of the scope resolution operator :: begins on page 104. The scope resolution operator allows reference to a type, object, function, or enumerator even though its identifier is hidden.

The parenthesis surrounding an expression do not change the unadorned expression itself.

The primary expression name is restricted to the category of primary expressions that sometimes appear after the member access operators . (dot) and –> . Therefore, name must be either an lvalue or a function. See also the discussion of member access operators.

An identifier is a primary expression, provided it has been suitably declared. The description and formal definition of identifiers is shown in Lexical Elements: Identifiers.

See the discussion on how to use the destructor operator ~ (tilde).

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!