0% found this document useful (0 votes)
2 views

Lab Inheritance Short

Uploaded by

ShAmy KhAn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab Inheritance Short

Uploaded by

ShAmy KhAn
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab – Inheritance

Note:
Test the child class in runner and call the overridden method.
Write explicit call to parent class constructor in child class.

1. Write a base class Computer that contains data members of


memorysize and storagesize .

Derive a Laptop class that is a kind of computer but also specifies the
object’s length and width. Member functions for both classes should
include a default constructor, a constructor to initialize all components
and toString().
Note:Use overriding for defining toString()

2. Write a class CommisionEmployee class that has attributes of


firstname,lastName,SSN, grossSales, CommisionRate. It has a
constructor to initialize, set and get functions, toString(). and a
function to calculate earnings.
Create another class BasePlusCommisionEmployee that inherits above
class. It has additional attributes of Salary. It also has set and get
functions, toString() and earnings function.

You might also like