

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: Computer Organization; Subject: Engineering: Electrical; University: University of Central Florida; Term: Unknown 2006;
Typology: Lab Reports
1 / 3
This page cannot be seen from the preview
Don't miss anything!


EEL 3801 Lab # Laboratory Assignment # EEL 3801 Introduction to Computer Engineering Topic: Inheritance. Turn in: .CPP file with screen output. Inheritance The concept of inheritance is another fundamental improvement in computer software development introduced by object-oriented programming. It keeps software developers from having to repeat lines of code over and over, yet tailor existing code to their needs without having to rewrite much of it. This assignment will introduce you to this concept.
1. Basic Inheritance: Perform the following tasks. a. Define a base class called Person, which has the following members: Data Items: Name [30] StreetAddress [30] City [20] State [3] Zip [6] Phone [12] Public Functions: get_info() // prompts the user for the above info print_info() // prints all the info for the class. Person() // constructor ~Person() // destructor b. Now define a class called Student, which is publicly derived from Person. It should have the following public members: Data Items: Major [30] // engineering, business, history, etc. Advisor [20] // who is his/her advisor credits // how many credits student has earned gpa // Grade Point Average Functions: find_info() // a function that asks the user for these inputs Student() // constructor ~Student() // destructor c. Write a short main() program which instantiates yourself as an object of the class Student.
EEL 3801 Lab # d. Supply all the information through the get_info() and find_info() functions called by a the user, and print the data out using the function print_info() as well as printing directly from main() through printf() for the "native" (i.e., not inherited) members of Student. e. You will have to write the functions get_info(), find_info(), and print_info(). Notice how Student inherits the members of the Person class automatically. Remember, however, that the derived class does NOT inherit constructors and destructors. f. Turn in the .CPP file and the screen output.
2. Access Specifiers for Inherited Members: Notice that the Student class does not have an access function for its "native" members. This is because, being public, they can be accessed directly from main() or any other function without the need for access functions. However, if you attempt to directly access the members inherited from Person, you will find that they are inherited as private. Perform the following tasks: a. Modify the main() program to try to access these directly without the access function. It should be impossible to do so. You can only access them through the access function print_info(). b. Turn in the .CPP file with the errors documented. 3. Protected Access Specifier: C++, however, gives us the ability to inherit "private" members of a class by labeling them as protected. This means that they act as if they are private to that class, but can be inherited by derived classes. To view this, perform the following tasks: a. Change the designation of the address and phone number members in Person to protected. b. Perform the same tasks as you did in #1 above. c. Turn in the .CPP file and the screen output. 4. Base Class Access Specifier: Another feature of inheritance is that the derived class can specify the access desired for its members to be inherited from the base class. This is called the base class access specifier. To view this, perform the following tasks: a. Modify the original Person class by adding some super- private info that is to be kept really private, the person's age, height and weight. The Person class should now look like this: private: age