Assume that a definition of the class Automobile has a composite object called m
ID: 3653533 • Letter: A
Question
Assume that a definition of the class Automobile has a composite object called myEngine of the class Engine. Also assume that all the data members of class Engine that contain information about the engine (such as displacement, horsepower, torque, etc.) are all private data members of the Engine class. Write the function prototype that would be required for an object of class Automobile to access the data member horsepower of the myEngine object, and explain your answer. Include what kind of a function this is, what class it would be defined in, what its access attribute is, and why it is necessary.Explanation / Answer
Assume that a definition of the class Automobile has a composite object called myEngine of the class Engine. Also assume that all the data members of class Engine that contain information about the engine (such as displacement, horsepower, torque, etc.) are all private data members of the Engine class.
Write the function prototype that would be required for an object of class Automobile to access the data member horsepower of the myEngine object,
//Function Prototype
double getHorsePower(){
return horsepower;
}
Include what kind of a function this is its accessor function in class Engine.
, what class it would be defined in, it will be defined in class Engine.
what its access attribute is it is public as it needs to be accessed by class Automobile.
, and why it is necessary it is necessary because Automobile need access to horsepower.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.