home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ANSICPP.ZIP / EX08006.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-24  |  409 b   |  23 lines

  1. // ex08006.cpp
  2. // Overloaded @ operator
  3. #include <iostream.h>
  4. #include <string.h>
  5.  
  6. class Name {
  7.     char name[25];
  8. public:
  9.     void display() { cout << '\n' << name; }
  10.     friend char * operator&(Name& nm) { return nm.name; }
  11. };
  12.  
  13. main()
  14. {
  15.     Name names[5];
  16.     for (int i = 0; i < 5; i++)    {
  17.         cout << "\nEnter a name: ";
  18.         cin >> &names[i];
  19.     }
  20.     for (i = 0; i < 5; i++)
  21.         cout << '\n' << &names[i];
  22. }
  23.