Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong with this class?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I have the following header file and than the accompanying file implementation, I am wondering if anyone can tell me what is wrong with it. The problem that is happening is that it runs withour errors but than it does not allow me to CIN the two numbers. Also do I need a main function? and if so what would it look like, i tried it below but it didn't work

*******************************************
//Formula.h
Class Formula{
private:
int pie, quad;
int AddSub();
public:
Formula(int const a, int const b); // constructor
};

*****************************************
// Formula.cc
int main()
{
return 0;
}

Formula::Formula(int a, int b){
pie = a;
quad = b;
Addsub()
}

void Formula::Addsub(){
cin >> a >> b;

int pieval = pie + quad;
int quadval = pie - quad;

cout << pieval << '/n' << quadval;
}
*********************
 
Soo how do I define an object in main? What does it look like? thanks
 
int main()
{
int a, b;
cin >> a >> b;
Formula f1(a, b);
return 0;
}

void Formula::Addsub(){

int pieval = pie + quad;
int quadval = pie - quad;

cout << pieval << '\n' << quadval;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top