Symbols

This page was translated by a robot.

An icon is a generic term for user-defined names in a program. In C, variables , functions , types and in C++ areas can also be represented and addressed by symbols. Upper and lower case letters, the numbers 0 to 9 and the underscore sign can be used for symbols. The first character of a symbol must not be a digit, the length of a symbol is arbitrary with today's compilers.

Variable

Function

Type

Namespace
float weight;

void print_message(){printf("Hello World!");}

typedef unsigned int uint;

namespace Test {
  int x1;
}

Details

Symbols are also sometimes called identifiers .

In addition to letters, digits and the underscore sign, the dollar sign is also permitted, but the use of this sign is outdated and, as far as we know today, is no longer used in the C and C++ languages.

In the C and C++ languages, symbols are considered case-sensitive, which means that a distinction is made between upper and lower case letters. The following symbols are all different: symbol, symbol, SYMBOL, SyMbOl.

A symbol can normally only exist once within an area, which means that each symbol is assigned to a specific area. However, in C++ it is allowed to overload functions, which means that multiple functions can exist with the same name but differing in the parameter list. See the function overloads page for details . In addition, there is already a structure in C that is not accessible to the programmer, which assigns symbols to a functionality and, accordingly, symbols with different assignments can exist side by side. However, with today's programming style, this assignment is hardly relevant for day-to-day programming work.

Type symbols are specified with the typedefkeyword , after which the symbol represents the specified (more or less complex) type. Note: typedefStrictly speaking, from the language, an specification is a variable with a special storage class.

Area symbols are only allowed in C++ and are defined with the namespace-keyword , the struct-keyword or the class-keyword , after which the symbol represents the specified area. A symbol within a range must always be addressed using the range operator:: , unless the position in the code is itself within that range. However, variables within a range can also be made generally available within a file using the using keyword .

Symbols are basically only placeholders and have no influence on the executable program. For this reason, they can be removed from the executable program during compilation (stripped: only bare code remains).

Next Chapter: Keywords, Directives