Lecture overview -- Keyboard shortcut: 'u'  Previous page: Declarations and definitions -- Keyboard shortcut: 'p'  Next page: Declaring several names together -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 6 : 42
Notes about C++
Basic facilities
The structure of a declaration

A declaration of a single entity consists of a four parts:

A specifier (optional), a base type, a declarator, and an initializer (optional)

  • The C++ Programming Language: Page 79 - 80
 

  unsigned int i = 7;
  const double d = 5.7;
  char* str[] = {"This", "is", "a", "string", "array"};
  extern short int ei;
  bool is_even(int a);
  Point p1(1,2);
  Pair q1 = {3,4};

Examles of declarations.

  • Specifier:

    • Storage class: auto, extern, mutable, register, static

    • CV qualifier: const, volatile

  • Base type

  • Declarator

    • The name being declared

    • Optional declarator operators - mimics their use as operators in expressions

  • Initializer

    • Assignment-like

    • Function-like