Ask a question to Desklib · AI bot

Ask NowBETA

Functions Accessible to Classes and Programs

Added on -2019-09-13

| 2 pages
| 497 words
| 197 views

Trusted by 2+ million users,
1000+ happy students everyday

1.Create a C++ program Create a Person class:oAdd the following variables (set access so that only this class can access them):NameCampusoInclude the following functions (do not take any user input in the functions. Pass all needed values in as parameters). Make all functions accessible to classes and programs outside the Person class:Set (mutator) functions for all variablesA display function to display the user's name and campus.In the main function:oCreate an array of Person objects. Set the size to of the array to 5.oAdd three people to the array. Do not gather user input. Instead, hard code the data. Make sure you include the name and campus for each person.oDisplay all information for each person by calling the display() function.Compile and run your code.Submit your source code as a plain text file with a .cpp extension. Make sure it compiles without error before submitting it.2.Create a C++ program Using the Person class from previous one:oModify the Person class:Set all variables so they are accessible by the Person class and all sub classes (not by any other class or program).oCreate a Student class:Student inherits from PersonAdd variables for ID and major. Set all variables so they are only accessible from the Student class.ID should be of type int.Add set functions for ID and major. Set the accessiblity so they can be accessed from anywhere.Add a function to display all information for the Student. This includes information inherited from Person.oCreate a Staff class:Staff inherits from PersonAdd variables for ID and department. Set all variables so they are only accessible from the Staff class.ID should be of type stringAdd set functions for ID and department. Set the accessibility so they can be accessed from anywhere.Add a function to display all information for the Staff member. This includes informatino inherited from Person.oIn main:Create one object of type Student and one object of type Staff.Gather all input for Student (name, campus, ID, major) from the user and use the set functions to set the values for the object..

Found this document preview useful?

You are reading a preview
Upload your documents to download
or
Become a Desklib member to get accesss

Students who viewed this