topical media & game development

talk show tell print

basic-program-solutions-07-Soln7-4.c

? / basic-program-solutions-07-Soln7-4.c


  // Soln7_4.cpp
  
  include <iostream>                   // For stream input/output
  
  using std::cin;
  using std::cout;
  using std::endl;
  
  class CRecord
  {
  public:
    int getRecord();
    void putRecord();
  
  private:
     int number;
     char name[15];
  };
  
  int CRecord::getRecord()
  {
     cout << "Enter a number: ";
     cin >> number;
  
     if (number != 0)
     {
        cout << "And a name: ";
        cin >> name;
     }
     return number;
  }
  
  void CRecord::putRecord()
  {
     cout << "The number and name are " << number 
          << " and \"" << name << "\"" << endl;
  }
  
  int main()
  {
    while (true)
    {
      CRecord record;
      if(record.getRecord() == 0)
        break;
      record.putRecord();
    }
     
    return 0;
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.