Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The assigment involves using many class files to output volume and areas of figu

ID: 3548297 • Letter: T

Question

The assigment involves using many class files to output volume and areas of figures.


My program works perfectly how it is now, but my instuctor wants the class files to use both a .h and .cpp file for each class. At the moment I am only using a .h file for each class.


Would appriciate help on how to split it into two files correctly. Let me know if there are any questions!



Below is one of the class .h files that needs to become a .h and a .cpp file.


The assigment involves using many class files to output volume and areas of figures. My program works perfectly how it is now, but my instuctor wants the class files to use both a .h and .cpp file for each class. At the moment I am only using a .h file for each class. Would appriciate help on how to split it into two files correctly. Let me know if there are any questions! Below is one of the class .h files that needs to become a .h and a .cpp file.

Explanation / Answer

Its simple. just put all the declarations in a.h file and all the definitions in a.cpp file.

For the above example that you gave, from line 8 to 20 will be in a.h file and the remaining which is definition part, from line 22 to 25 will be in a.cpp file.

So, in summary, a.cpp file will contain function definition i.e->

void Cylinder :: set_values (double x, double y)

{

    height=x;

    radius=y;

}

double Cylinder :: volume ()

{

your code

}

double Cylinder :: area ()

{

your code

}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote