Hello I was making a program called englishweight and it has three main components englishweight.h which is a class declaration, englishweight_def.cpp which defines the public member fucntions, and EW_driver which uses the class to calculate what to do with the englishweight and preforms very basic operations. My program works WITHOUT englishweight_def.cpp when i define the functions within the englishweight.h class but gives me 23 errors when i try and use englishweight_def.cpp!!! Of those errors it tries to make me give the constructor a type and when i do it gives me 25 errors.
Here is the source code:
englishweight.h
class englishweight{
private:
float number;
float eng_weight;
//not englishweight because IDE thinks it is constructor
public:
englishweight();
/*{
number=0;
eng_weight=0;
};*/
float getnumber();
/*{
return number;
};*/
float getweight();
/*{
return eng_weight;
};*/
void def_number(float defn);
/*{
number=defn;
};*/
void def_weight(float defw);
/*{
eng_weight=defw;
};*/
};
Englsihweight_def.h:
#include"englishweight.h"
#include<iostream>
englishweight::englishweight()
{
number=0;
eng_weight=0;
};
float englishweight::getnumber()
{
return number;
};
float englishweight::getweight()
{
return eng_weight;
};
void englishweight::def_number(float defn)
{
number=defn;
};
void englishweight::def_weight(float defw)
{
eng_weight=defw;
};
EW_driver.cpp:'
#include<iostream>
#include"Englishweight.h"
#include"englishweight_def.cpp"
using namespace std;
int main()
{
float defw=0; //define float eng_weight
float defn=0;//define number
float defo=0;//define ounces(part of defw seen later)
class englishweight testing;
cout<<"Welcome to Englishweight V 1.0!"<<endl;
system("pause");
system("cls");
cout<<"Please input a weight-pounds then ounces."<<endl<<"Pounds: ";
cin>>defw;
cout<<endl<<"Ounces: ";
cin>>defo;
cout<<defo;
//system("cls");
cout<<"Now enter a number."<<endl<<"number: ";
cin>>defn;
if(defo!=0)
{
cout<<endl<<"@@@@@@@@@@"<<endl<<"defo before: "<<defo;
cout<<endl<<"defw before: "<<defw;
defo=(defo/16.0); //convert ounces to pounds (wats the 16, 16.0 difference?)
defw=(defw+defo); //add the converted weight to the ounces to get the final eng_weight
cout<<endl<<"defo after: "<<defo;
cout<<endl<<"defwafter: "<<defw<<endl<<"@@@@@@@@@"<<endl;
}
testing.def_number(defn); //use def_number and def_weight functions to define eng_weight
testing.def_weight(defw);
cout<<"***************"<<endl<<"Englishweight: "
<<testing.getweight()<<endl<<"Number: "<<testing.getnumber()<<endl<<"defw: "<<defw<<endl<<"defn: "<<defn<<endl<<"defo: "<<defo<<endl<<"***************"<<endl;
cout<<endl<<"Englishweight + Englishweight is: "<<( (testing.getweight() )*2);
cout<<endl<<"Englishweight - Englishweight is: "<<"0"; //will always be 0 so no need to use processing power
cout<<endl<<"Englishweight / Englishweight is: "<<"1"; //will always be 1 so no need to use processing powercout<<endl<<"Englishweight * number is: "<<( (testing.getweight()) * (testing.getnumber()) );
cout<<endl<<"Number * Englishweight is: "<<( (testing.getnumber()) * (testing.getweight()) );
cout<<endl<<"Englishweight / number is: "<<( (testing.getweight()) / (testing.getnumber()) );
system("pause");
return 0;
}