Solved by Expert Tutors
Solved by Expert Tutors
Question

Aa class Employee double Earnings() Class SalariedEmployee Employee double Earnings() Class HourlyEmployee

having private data members firstname as string, lastname as string and SSN(social security number) as string. Write getter and setter function for these data members. Also write default and parameterized constructor for this class. Write pure virtual function . Another virtual function voidPrint() which prints first name, last name and SSN of Employee.

derived from class. Private Data Member for this class is weeklySalary as double. The public member functions include a constructor that initializes first name, last name, SSN (social security number) and weekly salary; a set function to assign a new non negative value to data member weeklySalary; a get function to return weeklySalary's value to the calling program. Function overrides pure virtual function of Employee class to provide a concrete implementation that returns the SalariedEmployee's   weeklySalary.   Function Print() of   class   SalariedEmployee   overrides Employee function void Print(). For this, call Employee Print function and getter of weeklySalary in this function.

is also derived from class Employee . Private Data members for this class are hours and wage of type double. The public member functions include a constructor that initialize first name, last name, SSN (social security number), an hourly wage and the number of hours worked; set function that assign new values to data members wage and hours (hours takes value from 0 to 168 and wage is non-negative), respectively, get functions to return the values of wage and hours, respectively. Function double Earnings() overrides pure virtual function of Employee class to provide a concrete implementation that returns wage  x hours if hours less than 40 else return 40 x wage + ( ( hours - 40 ) x wage x 1.5 ); Now Function   void Print() of class HourlyEmployee overrides Employee class function void Print(). For this call Employee Print function and return wage.

In main() create objects of child classes and Parent and call Earning() and Print() functions along with their name and SSN. Also elaborate if polymorphism is being implemented here.

Step-by-step answer

The student who asked this found it Helpful

, dictum vitae odi


sum dolor sit amet,


et, consectetur

Donec al

, ultrices ac magn

ec aliquet. Lorem ips

risus ante, dapibus

e vel laoreet


a mole

icitur laoreet. Nam risus

sum dolor sit a


itur laoreet. Nam risus ante,

usce dui lectus, congue vel laoreet ac, dictum vita


usce dui

ng elit. Nam lacinia pulvinar to

amet, consectetur adipiscing el

s ante, dapibus a moles


, dictum


ec aliquet. Lorem ipsum

ipsum dolor sit amet,

lestie consequat,


e vel laoreet ac, dictum

fficitur laoreet. Nam risus an

icitur laoreet. Nam risu


icitur laoreet. Nam risus


dictum vitae odio. Donec aliquet. Lorem ipsum do

Donec aliquet. Lorem

risus ante, dapibus


o


ipsum dolor sit amet, conse

inia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a m


o


usce dui

lestie consequat, ultrices ac magna. Fusce

onec aliquet. Lorem i

o

tesque dapibus efficitur laoreet. Nam risu

s ante, dapibus a mol

o

m ipsum dolor sit amet, consectetur

inia pulvinar

o


, dictum


rem ipsum dolor sit amet, consect

fficitur laoreet. Nam

o

icitur laoreet. Nam risus ante,

amet, consectetur ad

o

ur laoreet. Nam risus ante

llentesque dapi

o



lestie consequat, ultrices ac magna. Fusce dui lectus, congue vel la

ia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur l

nec facilisis. Pellentesque dapibus ef

Donec al

ipsum dolor sit amet, consec

, consectet

llentesque dapibus ef

ia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a m

sum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet



iscing elit. Nam lacinia pulvinar to

ec aliquet. Lorem ipsum dolor


ctum vitae odio. Don

a. Fusce dui lec

u


dictum vitae odio. Donec aliquet. Lorem ipsum do

onec aliquet. Lorem ipsum dolor sit amet, consecte

ipiscing elit.

sque dapibus efficitur laoreet

ipsu

risus ante, dapibus a molestie consequat, ultrices

o

a molestie consequat, ultrices ac magna. Fu

sum dolor sit amet, con

o


molestie consequat, ultrices ac magn

sum dolor sit amet, con

o

ur laoreet. Nam risus ante, da

ur laoreet. Nam risus ante, dapibus a m

, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing

o


ec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing eli

ia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur l

, consectetur adipiscing elit. Nam la

Donec al

ec facilisis. Pel

ec facilisis. Pe

a mole

llentesque dapib

risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dic

Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet.

risus ante, dapibus a molesti

ia pulvinar tortor nec faci


Donec aliquet. Lorem

dictum vitae odio. Do

ctum vitae odio. Don

a. Fusce dui lec

u


amet, consectetur adipiscing elit. Nam la

ce dui lectus, congue vel l

s a molestie consequat, ultrices ac

a molest

e vel laoreet ac, dictum vitae odio. Donec aliquet. Lo

o

ia pulvinar tortor nec facilisis. Pelle

ultrices a

dictum vitae odio. Donec aliq

a molest

risus ante, dapibus a molestie consequat, ultrices ac magn

o


ctum vitae odio. Donec aliquet. L

itur laoreet. Nam

o

tesque dapibus efficitur laoreet

, dictum vitae

o

ce dui lectus, congue vel laoreet

m risus ante, dapi

a. Fusce dui lectu

lestie consequat, ultrices ac magn

ec f

ur laoree

ipiscing elit. Nam lacinia pulvinar tortor nec facilis

ec f

o

ctum vitae odio. Donec alique

iscing elit. Nam lacinia pulvinar tortor

lestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur

o


Fusce dui

ctum vitae odio. Donec aliquet. Lorem ipsum d

ur laoreet. Nam ris

s ante, dapibus a

or nec facilisis

Donec aliq

a molestie co

trices ac ma

rem ipsum dolor sit

ac, dictum

rem ipsum


congue vel laoreet ac, dictum vitae odio. Donec alique

onec aliquet


ce dui lectus, congue vel


or nec

Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar

ce dui lectus, co

dictum vitae odio. Donec aliquet. Lor

ipiscing elit. Nam lacinia pulvinar tortor nec facilis

sum dolor

Donec aliquet. Lorem ipsum dolo


m ipsum dolor sit amet, consectetur a

entesque dapibu


, ultrices ac magna. Fusce dui le

ac, dictum vit


ipiscing elit. Nam lacinia

ur laoree


molestie cons

sque dapibus efficitur laoreet. Nam risus an

fficitur laoreet. Nam

ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae o

o

sus ante, dapibus

ongue vel laoreet ac, dictum vitae

dictum vitae od


fficitur laoreet. Nam risus ante, d

ctum vitae odi

tesque dapibus efficitur laoreet. Nam risus ante, dapibus a molesti

o



o


ongue vel laoreet ac, dictum vitae odio. Donec alique


ce dui lectus, congue vel

usce dui lectus, congue vel laoreet ac, dictum vitae odio. Don

ur laoreet. Nam risus

o


onec aliqu

cing elit. N

o

acinia pulvi
  • ec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulv
  • ipiscing elit. Nam
  • emp1.jpg

emp1.jpg
fficitur laoreet. Nam risus ante, dapibus a molestie itur laoreet. Nam risus ante, dapibus onec aliquet. Lorem ipsum dolor sit amet, et, consectetur adipiscing elit. Nam lacinia pulvinar tort

Subscribe to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Let our 24/7 C++ Programming tutors help you get unstuck! Ask your first question.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes