calling a double for a header file to .cpp file
Jul 22, 2012 at 10:47am UTC
hi im trying to call a double from my header file to my .cpp file but my complier keeps giving me an error. i dont know what im doing wrong here. plz help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
//header file
#ifndef RIGHTTRIANGLE_H
#define RIGHTTRIANGLE_H
class RightTriangle
{
public :
RightTriangle(double newbase, double newheight);
double GetArea();
double GetPerimeter();
void Print();
double base;
double height;
};
#endif
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
//.cpp file
#include "RightTriangle.h"
#include<iostream>
#include<cmath>
using namespace std;
RightTriangle::RightTriangle(double GetArea)
{
double GetArea
RightTriangle Area;
Area.GetArea = .5*base*height;
return Area;
}
void RightTriangle::Print()
{
cout << "Area of Triangle = " << .5*base*height << endl;
}
Jul 22, 2012 at 11:08am UTC
In the header file you have declared the constructor to take one argument but in the source file it's defined to take only one argument.
Topic archived. No new replies allowed.