Lecture overview -- Keyboard shortcut: 'u'  Previous page: The structure of a declaration -- Keyboard shortcut: 'p'  Next page: Declarations as statements - declarations in conditions -- 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 7 : 42
Notes about C++
Basic facilities
Declaring several names together

Several comma-separated declarators - with associated initializers - may share the same base-type and specifier

  • The C++ Programming Language: Page 80
 

  unsigned int i = 7,  j[3],  *k = &i;
  const double d = 5.7,  pi = 3.14159,  &dr = d;
  char *str[4],  ch = 'a';
  extern short int ei;
  bool is_even(int a), 
       is_odd(int a);
  Point p1(1,2), 
        p2;
  Pair q1 = {3,4}, 
       q2 = {5,6};

Examles of declarations of multiple names.

"Such constructs makes a program less readable and should be avoided"

Nevertheless, I use multiple name declarations frequently in these slides and notes