Example of Access for Classes and Structures


/************************************************************************
*

In the following example, main() has access to the members of X even though X is declared as using the keyword class:

                                                                        *
************************************************************************/


// This example declares a structure, then declares a class
// that is an object of the structure.

#include <iostream.h>

struct x {
      int a;
      int b;
      } ;

class x X;

void main() {
      X.a = 0;
      X.b = 1;
      cout << "Here are e and f " << X.a << " " << X.b << endl;
      }