Inheritance and copy constructor
Not what you're looking for?
Problem 1. You are to design an abstract class called Employee whose members are as given below (make them protected):
Data members:
char *name
long int ID
Two constructors:
A Default constructor // initialize data members to the default value and a copy constructor
Methods:
setPerson (char *n, long int id) //allows user to set information for each person
A function called Print () // should be a virtual function, that prints the data attributes of the class.and a destructor
Also define two classes that derived from class Employee, called Manager and Secretary. Each class should inherit all members from the base class and has its own data members and member functions as well.
The Manager should have a data member called degree for his/her undergraduated degree (e.g. diploma, bachelor, master, doctor), the Secretary should have her contract (can be a Boolean value 1/0 for permanent/temporary). All member functions of derived class should be overrided from their base class.
Write the following main() to test your classes
int main() {
Person * p = new Manager("Bruce Lee", 0234567, "Dr.");
P.print();
Secretary p2;
p2.setPerson("Wilma Jones", 0341256, "permanent");
delete p;
p = & p2;
p.Print();
return 0;
}
Do you see any polymorphic behavior ? What do you learn from this example ?Problem 2: Write a template for a function that displays the contents of an array of any data type.
Problem 3: Write a function that searches a numeric array for a specified value. The function should return the subscript of the element containing the value if it is found in the array. If the value is not found, the function should throw an exception.
Purchase this Solution
Solution Summary
This Solution is demonstrated in a .cpp file.
Purchase this Solution
Free BrainMass Quizzes
Inserting and deleting in a linked list
This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.
C# variables and classes
This quiz contains questions about C# classes and variables.
Javscript Basics
Quiz on basics of javascript programming language.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.