Question
The following is a formal description of the Cylinder object type. The description includes the constructor (Cylinder) that initializes the radius and height attributes of
The following is a formal description of the Cylinder object type. The description includes the constructor (Cylinder) that initializes the radius and height attributes of an object and access operations to update the attributes or retrieve their current values.
Attributes:
myRadius
myHeight
Operations:
Cylinder Assigns zero to both radius and height of an uninitialized cylinder (default constructor)
Cylinder Takes initial values radius and height as arguments and assigns them as the myRadius and myHeight of the cylinder (explicit constructor)
endArea Computes ? * myRadius2 and returns the value as the end area of the cylinder
sideArea Computes 2 * ? * myRadius * myHeight and returns the value as the side area
volume Computes the end area * myHeight and returns the value as the volume
setDimensions Takes values radius and height as arguments and updates the attributes myRadius and myHeight to have the values radius and height respectively ( a function to change attributes of a cylinder)
getRadius Returns the current value of myRadius
getHeight Returns the current value of myHeight
The requirements of todays lab are to implement a cylinder object. Write the class definition and put it into a header file called cylinder.h and put the function implementation into cylinder.cpp. Create a driver to test your class definition. Turn in the source listing of the two class cylinder files
Step 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