class header+ implementation
- by igor
what am I doing wrong here? I keep on getting a compilation error when I try to run this in codelab (turings craft)
Instructions:
Write the implementation (.cpp file) of the GasTank class of the previous exercise. The full specification of the class is:
A data member named amount of type double.
A constructor that no parameters. The constructor initializes the data member amount to 0.
A function named addGas that accepts a parameter of type double . The value of the amount instance variable is increased by the value of the parameter.
A function named useGas that accepts a parameter of type double . The value of the amount data member is decreased by the value of the parameter.
A function named getGasLevel that accepts no parameters. getGasLevel returns the value of the amount data member.
class GasTank{
double amount;
GasTank();
void addGas(double);
void useGas(double);
double getGasLevel();};
GasTank::GasTank(){
amount=0;}
double GasTank::addGas(double a){
amount+=a;}
double GasTank::useGas(double a){
amount+=a;}
double GasTank::getGasLevel(){
return amount;}