kenny.kor
February 18th, 2008, 06:33 PM
I'm very new to oop and the entire concept is being introduced in the .NET framework.
Anyways, I'm not sure if my data types are correct, I try different ways but everything I'm doing seems to be wrong. I'm getting compiler errors on line 5 in my fluid.cpp file. The problem lies withing the REDUCE() function.
if anyone could show me what's wrong it'd be very helpful. thanks
//fluid class
#pragma once
class fluid{
double gal,qrt,pnt;
void reduce(double a);
public:
fluid(double gallon = 0.,double quart = 0.,double pint = 0.)
{gal = gallon; qrt = quart; pnt = pint;}
double getGal(void);
double getQrt(void);
double getPnt(void);
void increment(double g,double q,double p);
fluid operator+(fluid& f);
}
//fluid cpp
#include "stdafx.h"
#include "fluid.h"
void fluid::reduce(){
while(pnt >= 2){
qrt += 1;
pnt -= 2;
}
while(qrt >= 4){
gal += 1;
qrt -= 4;
}
}
double fluid::getGal(void)
{return gal;}
double fluid::getQrt(void)
{return qrt;}
double fluid::getPnt(void)
{return pnt;}
void increment(double g,double q,double p){
}
fluid fluid::operator+(fluid& f){
}
Anyways, I'm not sure if my data types are correct, I try different ways but everything I'm doing seems to be wrong. I'm getting compiler errors on line 5 in my fluid.cpp file. The problem lies withing the REDUCE() function.
if anyone could show me what's wrong it'd be very helpful. thanks
//fluid class
#pragma once
class fluid{
double gal,qrt,pnt;
void reduce(double a);
public:
fluid(double gallon = 0.,double quart = 0.,double pint = 0.)
{gal = gallon; qrt = quart; pnt = pint;}
double getGal(void);
double getQrt(void);
double getPnt(void);
void increment(double g,double q,double p);
fluid operator+(fluid& f);
}
//fluid cpp
#include "stdafx.h"
#include "fluid.h"
void fluid::reduce(){
while(pnt >= 2){
qrt += 1;
pnt -= 2;
}
while(qrt >= 4){
gal += 1;
qrt -= 4;
}
}
double fluid::getGal(void)
{return gal;}
double fluid::getQrt(void)
{return qrt;}
double fluid::getPnt(void)
{return pnt;}
void increment(double g,double q,double p){
}
fluid fluid::operator+(fluid& f){
}