C++ * Add constructors to the code - a default and parameterized constructor to each. * Write an .h interface and a .cpp implementation for each class * Write an Drive/Test file that tests the constructors and functions * Write a UML class diagram for each class ******************************************************************** // Sample Class - Print and Study, RUN the code... #include #include using namespace std; // STEP 1 - DEFINE THE new datatype/Class 'aThing' class aThing { public: // Public means that is can be access in step 3 with the dot notation double getWeight(void) { return weight; } // public functions accessible by dot notation void setWeight( double inWeight ) { weight = inWeight; } private: // Private means that it can NOT be accessed with the dot notation, but indirectly with a public function double weight; // private variables only accessible by a function }; int main() { // STEP 2 - DECLARATION - USE the new datatype/class 'aThing' in a Declaration statement to create 'ThingOne'. aThing ThingOne; // STEP 3 - Use the OBJECT defined in step 2 - With dot notation ThingOne.setWeight(110); cout << "Use Function/Method get Weight - "<< "Weight is: " << ThingOne.getWeight() << endl; //system("PAUSE"); // MAC User comment this line out. return 0; }
C++
* Add constructors to the code - a default and parameterized constructor to each.
* Write an .h interface and a .cpp implementation for each class
* Write an Drive/Test file that tests the constructors and functions
* Write a UML class diagram for each class
********************************************************************
// Sample Class - Print and Study, RUN the code...
#include <iostream>
#include <string>
using namespace std;
// STEP 1 - DEFINE THE new datatype/Class 'aThing'
class aThing {
public: // Public means that is can be access in step 3 with the dot notation
double getWeight(void) { return weight; } // public functions accessible by dot notation
void setWeight( double inWeight ) { weight = inWeight; }
private: // Private means that it can NOT be accessed with the dot notation, but indirectly with a public function
double weight; // private variables only accessible by a function
};
int main()
{
// STEP 2 - DECLARATION - USE the new datatype/class 'aThing' in a Declaration statement to create 'ThingOne'.
aThing ThingOne;
// STEP 3 - Use the OBJECT defined in step 2 - With dot notation
ThingOne.setWeight(110);
cout << "Use Function/Method get Weight - "<< "Weight is: " << ThingOne.getWeight() << endl;
//system("PAUSE"); // MAC User comment this line out.
return 0;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)