Employees

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 8
Reputation: effective is an unknown quantity at this point 
Solved Threads: 0
effective effective is offline Offline
Newbie Poster

Employees

 
0
  #1
May 8th, 2009
  1. You are to design a class class called Employer data members:
  2.  
  3. char name[]
  4. long int ID
  5. double salary ,
  6.  
  7. and two constructors
  8.  
  9. _Default construtor Person ()
  10. _Copy constructor Person
  11. ( char n[30],long int id,double s)
  12. _setPerson (char n[30],long int id,double s)
  13. that allows user to set information for each person
  14.  
  15. You have to define two classes that derived from class
  16. Employee, called Manager and Secretary correspondingly. Each class should inherit all members from the base
  17. class and has its own data members and member function as well. For example the
  18. Manager should have a data member called degree for his/her undergraduated degree (e.g. diploma, bachelor, master, doctor), the
  19.  
  20. Secretary should have her contract (permanent, temporary). All member functions of derived class should be overiided from
  21. their base class. Each derived class should have an operator << which allows user to output a person’s information to the screen.
  22.  
  23. Write the following main() to test your classes
  24.  
  25. int main()
  26. {
  27. Person p(“Vinh Nguyen”,1234567,500.0);
  28. Manager p1(“An Nguyen Vinh”, 0234567, 1000, Dr.);
  29. Secretary p2;
  30. p2.setPerson(“Lan Vu”, 0341256, 400, permanent);
  31. cout << “Manager p1 is “ << p1;
  32. cout << “Secretary p2 is “ << p2;
  33. return 0;
  34. }

Help me !
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Employees

 
0
  #2
May 8th, 2009
Might want to try it yourself first looks like the description is pretty detailed. I'll wait while you give it a shot.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 8
Reputation: effective is an unknown quantity at this point 
Solved Threads: 0
effective effective is offline Offline
Newbie Poster

Re: Employees

 
0
  #3
May 8th, 2009
  1. class Employee {
  2. public:
  3. Employee(string theName, float thePayRate);
  4.  
  5. string getName() const;
  6. float getPayRate() const;
  7.  
  8. float pay(float hoursWorked) const;
  9.  
  10. protected:
  11. string name;
  12. float payRate;
  13. };
  14. Employee::Employee(string theName, float thePayRate)
  15. {
  16. name = theName;
  17. payRate = thePayRate;
  18. }
  19.  
  20. string Employee::getName() const
  21. {
  22. return name;
  23. }
  24.  
  25. float Employee::getPayRate() const
  26. {
  27. return payRate;
  28. }
  29.  
  30. float Employee::pay(float hoursWorked) const
  31. {
  32. return hoursWorked * payRate;
  33. }
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Employees

 
2
  #4
May 8th, 2009
See, you're more than capable of doing what the description says, you're just overthinking it. Follow the directions closely and read in your book about Inheritance and Operator Overloading and you'll have it done in no time.

(You're probably thinking I'm being mean by not giving you the answer but if you don't learn now you'll just keep needing help)
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 8
Reputation: effective is an unknown quantity at this point 
Solved Threads: 0
effective effective is offline Offline
Newbie Poster

Re: Employees

 
0
  #5
May 8th, 2009
thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 8
Reputation: effective is an unknown quantity at this point 
Solved Threads: 0
effective effective is offline Offline
Newbie Poster

Re: Employees

 
0
  #6
May 24th, 2009
My solution :
  1. class Employee {
  2. public:
  3. Employee(const char* aName, const Manager* aManager);
  4. const char* name(void) const;
  5. const Manager* manager(void) const;
  6. private:
  7. const char* theName;
  8. const Manager* theManager;
  9. };
  10.  
  11. class Manager : public Employee {
  12. public:
  13. Manager(const char* aName,
  14. const Manager* aManager,
  15. Secretary* aSecretary = 0);
  16. void setSecretary(Secretary* aSecretary);
  17. Secretary* secretary(void);
  18. private:
  19. Secretary* theSecretary;
  20. };
  21.  
  22. class Secretary : public Employee
  23. {
  24. public:
  25. Secretary(const char* aName,
  26. const Manager* aManager);
  27. };

Please help me complete classes !
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC