In C++, how does using pointers and references work in as parameters in a function of a class?   It is used a lot, and I dont really know how to use this as parameter in a function of a class, or in Polymorphism as well.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In C++, how does using pointers and references work in as parameters in a function of a class?

 

It is used a lot, and I dont really know how to use this as parameter in a function of a class, or in Polymorphism as well.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

C++ programming

Overview

This is a demonstration an ability to implement inheritance, composition, and overloaded operators in a program.

Pretend to be working in the IT department for a corporation and have been tasked with developing an application to manage assigning people to a team. This process involves creating a team with a name and a purpose, the assignment of people in the team, and the assignment of a person to lead the team.

Use inheritance to facilitate the reuse of code and operator overloading to allow the usage of familiar operators tailored specifically to the Person, TeamMember, and Leader classes. Composition is also demonstrated in using a Team class that contains objects of the TeamMember and Leader classes.

You will need to develop several classes to maintain this information:
Team, Person, TeamMember, Leader, and Date.

The characteristics of TeamMember and Leader are shown below:

TeamMember:                                                            Leader:

ID (string)                                                                    ID (string)

First Name (string)                                                       First Name (string)

Last Name (string)                                                        Last Name (string)

Birthdate (Date)                                                           Birthdate (Date)

Department (string)                                                      Division (string)

Date hired (Date)                                                          Date promoted (Date)

Position (string) (i.e. Programmer, Writer, etc.)              Title (string)

SkillLevel (string) (Entry Level, Skilled, Master)           Last team lead (string)

Last performance rating (double) (1.0-5.0)                     Annual salary (double)

Strings will not be acceptable substitutes for date fields.

Person class (base class)

The Person class should contain data members that are common to both TeamMembers and Leaders in the above list.

Write appropriate member functions to store and retrieve information in the member variables above. Include constructors and destructors information as well.

TeamMember class and Leader class. (derived classes)

Both the TeamMember and Leader classes must be derived from the Person class.

Each must have the member variables shown above that are unique to each class. The data members that are common to both classes must be inherited from the Person class.

The constructor in the derived class must call the constructor in the base class correctly through the constructor definition.

Write member functions to store and retrieve information in the appropriate member variables. Be sure to include a constructor and destructor in each derived class.

In each derived class, the << operator should be overloaded to output, neatly formatted, all of the information associated with a team member or leader.

Team class

The Team class has a name data member (i.e. a Team’s name might be “Project ABC”).

The Team class has a purpose data member (i.e. a Team’s purpose might be “Feasibility study of project ABC”).

The class contains a Leader object that represents the employee assigned to lead the team.

The class contains a vector of TeamMember objects that represent the employees assigned to the team.

The class has an integer variable, teamSize, that represents the number of team members the team needs.

The Team class supports operations to assign a leader to the team, assign team members to the team, and list all of the team information, including its name, purpose, leader, and team members assigned to it.

develop a function named sortTeamMembers() that uses the sort function to sort this vector. The sort function is part of the <algorithm> library.

You can put tokenizeDate in any class that you deem appropriate.

Main()

***write a main() function that begins by prompting the user for the name, purpose, and size of the team:

“T” should allow the user to develop a TeamMember record and assign the TeamMember to the Team. Unless team is full, then it should say “Team is full”

“A” should allow the user to develop a Leader record and assign the Leader member to the team as the leader.

“L” should list ALL of the team information, including the information about each TeamMember assigned to the team, (sorted by ID number), as well as all of the information about the Leader assigned to lead the team.

The user should be able to develop and assign only ONE Leader to the team but develop and assign as many TeamMembers to the team as the size allows.

“Q” should allow the user to exit the application.

Note: The user should be able to add repeatedly (until the team capacity is reached) and to list repeatedly until he or she selects “Q” to quit.

***For each TeamMember, the first name and last name are output on the same line, separated by a space.

***For the Leader, the format should be this: first name [space] last name [dash] title [dash] division

 

 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education