Using the file below do the following:
Create a data file named employee.bin
Add mutators and accessors functions for the 3 data fields.
Add a default constructor and one that takes in parameters
for the three data fields.
Finally add a destructor to your class!!!!
Make sure you use the constructor in Instantiating your object and that you also print out all data fields.
For Extra Credit add just one more class contain just one field and that contains all of the above! (A default constructor and one that takes in parameters and a destructor!)
Add a method to your Employee class!
Try and write all fields out using a friend function!!!
Remember all of this is demonstrated by the files above!!! I am testing your
understanding of the presented material!
#include
#include #include #include #include "getline.inc" class employee { char Xname [81]; char Xaddress [81]; int Xempnum; public: void set_Xname(); // Remember set is always void char * get_Xname(); void set_Xaddress(); char * get_Xaddress(); void set_Xempnum(); int get_Xempnum (); void display(); };;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; // Don't forget the ;;;;;; //PROTOTYPES int getline(char *s,int lim); void employee::set_Xname() { getline(Xname,80); } char * employee::get_Xname() { return Xname; } void employee::set_Xempnum() { cin >> Xempnum; } int employee::get_Xempnum() { return Xempnum; } void employee::set_Xaddress() { getline(Xaddress,80); } char * employee::get_Xaddress() { return Xaddress; } void employee::display() { cout < "\nemployee="" xname:="" "="">< xname;="" cout="">< "\nemployee="" xaddress:="" "="">< xaddress;="" cout="">< "\nemployee="" xempnum:="" "="">< xempnum;="" }="" display="" void="" main()="" {="" employee="" emprec;="" declare="" my="" object="" cout="">< "\n="" enter="" the="" xname="" ";="" emprec.set_xname();="" cout="">< "\n="" your="" xname="" is="" "="">< emprec.get_xname();="" cout="">< "\n="" enter="" the="" xaddress="" ";="" emprec.set_xaddress();="" cout="">< "\n="" your="" xaddress="" is="" "="">< emprec.get_xaddress();="" cout="">< "\n="" enter="" the="" xempnum,="" ";="" emprec.set_xempnum();="" cout="">< "\n="" your="" xempnum="" is="" "="">< emprec.get_xempnum(); emprec.display(); }//main emprec.get_xempnum();="" emprec.display();=""> emprec.get_xempnum(); emprec.display(); }//main>