EECE 330 Homework 1 Assignment, Fall 2011
American University of Beirut · Data Structures and Algorithms · 1 page
Stuck on a question? A tutor can walk you through it.
More EECE 330 files
- Homework 1 · Fall 2015HomeworkView
- Homework 4 Assignment · Fall 2011HomeworkView
- Homework 3 Assignment · Fall 2011HomeworkView
- Homework 2 Assignment · Fall 2011HomeworkView
- Homework · Spring 2008HomeworkView
- Homework · Spring 2008HomeworkView
- Other Extra Lecture About Dynamic Programming · Spring 2017LabView
- Useful File MCQ · Fall 2015FileView
Show the text of this homework
EECE 330 Assignment 1, Inheritance, virtual functions, and templates
Write a pure virtual class Person which has a name (string) and an age (int). You cannot instantiate
from it.
Derive from it two classes: Teacher which has a salary(int) and Student which has a grade (char) and
fees (double). Provide constructors with parameters and readers and writers for these two classes.
Also provide a virtual function print for each.
Write a main program which declares an array of pointers (size 4) to person. Write a loop to choose a
Teacher or Student object (t or T for teacher, s or S for student otherwise display wrong choice), and
then read the required parameters.
Finally, pass the array to a template sort function to sort records in ascending order according to
name.