Functions Accessible to Classes and Programs

Added on - 13 Sep 2019

  • Dissertation

    type

  • 2

    pages

  • 497

    words

  • 50

    views

  • 0

    downloads

Showing pages 1 to 1 of 2 pages
1.Create a C++ programCreate 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 neededvalues in as parameters). Make all functions accessible to classes and programs outside thePerson 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.Makesure 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 errorbefore submitting it.2.Create a C++ programUsing 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 (notby 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 theStudent class.ID should be of type int.Add set functions for ID and major.Set the accessiblity so they can be accessedfrom anywhere.Add a function to display all information for the Student.This includes informationinherited from Person.oCreate a Staff class:Staff inherits from PersonAdd variables for ID and department. Set all variables so they are only accessiblefrom the Staff class.ID should be of type stringAdd set functions for ID and department.Set the accessibility so they can beaccessed from anywhere.Add a function to display all information for the Staff member.This includesinformatino 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 setfunctions to set the values for the object..
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document