Question: Help!!! C++ programming How to convert into template classes Test each with Implicit int, float, double, long int. Test each with explicit int, float, double,
Help!!! C++ programming How to convert into template classes
Test each with Implicit int, float, double, long int.
Test each with explicit int, float, double, long int.
Header.h
#ifndef Header_h
#define Header_h
class aThing // Identification of Class
{
public:
double getWeight(); // Public function getWeight, get the weight
void setWeight(double inWeight); // Public function setWeight, set the weight by users
~aThing()
{
cout << "This is a deconstructor." << endl; //This defines the deconstructor of the class.
}
private:
double weight; // Private variable
};
#endif /* Header_h */
Source.cpp
#include
#include
#include
using namespace std;
#include "Header.h"
double aThing::getWeight() { return weight; } //Implementation of the function getWeight
void aThing::setWeight(double inWeight)
{
weight = inWeight; //Implementation of the function setWeight
}
Main.cpp
#include
#include
using namespace std;
#include "Header.h"
int main()
{
aThing ThingOne; // DECLARATION - USE the new datatype/class 'aThing' in a Declaration statement to create 'ThingOne'.
ThingOne.setWeight(110);//Use the OBJECT defined - With dot notation
cout << "Use Function/Method get Weight - " << "Weight is: " <<
ThingOne.getWeight() << endl; // Output the result on screen
// system("PAUSE"); // Mac not Support
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
