im writing a program that gets employee info.
employee number
compensation
employee type
date of hire
i have 1 class for the employee info:
and another class for a date of hire:Code:class employee { private: int number; float comp; enum etype { laborer, secretary, manager }; public: void input() { char n; cout << "Enter in employee number : "; cin >> number; cout << "Enter employee comp: "; cin >> comp; cout << "Enter in employee type(1 = laborer,2 = secretary,3 = manager): "; cin >> etype; } void display() { cout << "emp#: " << number << endl; cout << "comp$: " << comp << endl; switch(etype) { case '1': cout << "type: laborer"; break; case '2': cout << "type: secretary"; break; case '3': cout << "type: manager"; break; } cout << endl; } };
my question is..would it be logical to just merge these together into one class? can i have a class within a class?Code:class date { private: int day; int month; int year; public: void getdate() { char n; cout << "enter in a date (mm/dd/yy): "; cin >> month >> n >> day >> n >> year; } void showdate() { cout << month << "/" << day << "/" << year; cout << endl; } };
if so, how do i define an instance. please keep in mind that the farthest ive gone in c++ is loops & decisions, functions, and classes. nothing else. im just beginning. thanks in advance for response and sorry for the lengthy code.Code:class emp { private: ...... public: ...... class date { ..and so on }; };



LinkBack URL
About LinkBacks


