Question: C++ please Learning Objectives - Write a class for object-oriented programming - Overload an object constructor - Define a custom arithmetic operator - Practice writing
C++ please





Learning Objectives - Write a class for object-oriented programming - Overload an object constructor - Define a custom arithmetic operator - Practice writing class functions Instructions In this lab, you will create a class definition for an object that represents a structural beam. This beam will have several primitive attributes such as tength and width. It will also have several member functions that either access or modify (mutator) these characteristics. The program is contained in three separate files using the structure discusksed in section 8.17 and the lecture. There are initial template files to start with, note that you can switch between the different files using the drop-down menu labelled "Current File" at the top of the editor window You will need to modify each of the three programs in each part discussed below Part A beam. h Recall that the header files contains only the function prototypes. In the header file, add a public constructor function that takes zeros parameters. Then add 3 private float variables named length, width, and depth. beam.cpp Write the constructor function that takes zero parameters that you just defined. In this function, set the following default values: length is 20 , depth is 12 , and width is 31.5% of the depth value. Then add code to output the following (be sure to use the variable names and not the actual values in your cout statement Beam created, Length: 20 depth: 12 width: 3.78 main. .pp Test your programming so far by putting the following into the body of main. cpp. Put this line of code between the int main() fline and the return 0 ; lines. Beam beaml; The output at this point should be Beam created. Length: 20 depth: 12 width: 3.78 Part is beam.h Now add a public accessor function prototype called getLength () that takes zero parameters, and returns a float. beam.cpp Write the getlength () function. Have it return the value of the private data member named length. main copp Test your programming so far by adding this line to your main program directly before the return 0 ; statement (but after what youy already have there). cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
