Question
A) Using CodeBlocks or your IDE of choice, create the files main.cpp, Person.h, and Person.cpp. Make sure that the files are all added to the
A) Using CodeBlocks or your IDE of choice, create the files main.cpp, Person.h, and Person.cpp. Make sure that the files are all added to the same project (main.cpp should be created when you first create a new project) so that the linker will link them together for us.
B) Cut and paste the starter files into your appropriate project files for the application, interface, and implementation.
C) Create three new Classes using inheritance. At least one should be a child of Person and at least one should be a grandchild of Person. Example: You could create Employee (child of Person), Student (child of Person), and GradStudent (child of Student, making it a grandchild of Person). Alternatively you could create Student (child of Person), GradStudent (child of Student, making it a grandchild of Person ), and UndergradStudent (child of Student, making it a grandchild of Person).
D) Each of your new classes must add at least one new private or protected data element (some new information this object stores), at least one mutator for giving this data a value, and at least one accessor for returning this value. Make sure your operations make sense in the context of the class you have designed. Example: Student is a person with a number of credit hours (int num_credits), so we need an accessor to return num_credits and we need a mutator to either set the number of credits or add a number of credits. GradStudent is a Student who can graduate with at least 30 credit hours (bool can_graduate). UndergradStduent is a Student who can graduate with at least 120 credit hours (bool can_graduate). Example: can_graduate shouldn't just be set true or false based upon a boolean argument but instead should be updated when the credit hours exceed the threshold.
E) Each of your new classes should have 2 constructors: A Default constructor and one which takes arguments for both its new data and all of Person's data. You can either make Person's data protected or else use the space after : to call Person's constructors.
F) Update the main function to demonstrate your new classes and their accessors / mutators. Test both the new functions you created for them and also the functions they inherited such as getName and getBirthdate.
File CSC275 Lab7Starter_main.cpp (231 B) #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started