/*************************************************/
// R. A. Hillyard
// stuRecord00.cpp
// November 2001
//
// Intro to user defined classes
// class definition with public member variables for data
// and public member functions for input and output
/*************************************************/
#include<iostream>
#include<string>
using namespace std;
class stuRecord
{
public:
//member functions
void output(); //prototype to output a stuRecord
void input(); //prototype to input a stuRecord
//data members
int idNum; //student id number
string first; //student last name
string last; //student first name
};
/*************************************************/
int main()
{
//declare objects of type stuRecord
stuRecord stu1, stu2, stu3;
stu1.input(); //get input for stu1
stu2.input(); //get input for stu2
stu3.idNum = 9999; //assign values to stu3 directly
stu3.first = "Analog";
stu3.last = "Device";
//output the records
stu1.output();
stu2.output();
stu3.output();
return 0;
}//end main
/*************************************************/
//member function to output a stuRecord
/*************************************************/
void stuRecord::output()
{ cout << idNum << " " + first + " " + last << endl; }
/*************************************************/
//member function to input data for a stuRecord
/*************************************************/
void stuRecord::input()
{
cout << "enter Id Number, first name and last name: ";
cin >> idNum >> first >> last;
}
/*************************************************/
/*********Program Output*************************
enter Id Number, first name and last name: 2345 Bart Simpson
enter Id Number, first name and last name: 8534 Jill Kelly
2345 Bart Simpson
8534 Jill Kelly
9999 Analog Device
*/