Jul 12, 2013 at 8:40pm UTC
HI I changed my compiler from borland to vs2008 and I am having this error
fraction calculator.obj : error LNK2019: unresolved external symbol "void __cdecl showfrac(struct fraction &)" (?showfrac@@YAXAAUfraction@@@Z) referenced in function _main
in the code given below..need help plz
#include<iostream>
using namespace std;
struct fraction
{
float num;
float den;
};
fraction add(fraction&,fraction&);
fraction sub(fraction&,fraction&);
fraction mul(fraction&,fraction&);
fraction div(fraction&,fraction&);
void getfrac(fraction&);
void showfrac(fraction&);
void main()
{
char op;
fraction f1,f2,ans;
cout<<"**********Welcome to my fraction calculator***********\n";
cout<<"Enter 1st fraction\n";
getfrac(f1);
cout<<"\nEnter 2nd fraction\n";
getfrac(f2);
againop:cout<<"\nEnter operation (+,-,*,/)\n";
cin>>op;
if(op!='+' && op!='-' && op!='*' && op!='/')
{
cout<<"\nInvalid operation entered\n";
goto againop;
}
system("cls");
cout<<"1st fraction entered!\n";
showfrac(f1);
cout<<endl;
cout<<"2nd fraction entered!\n";
showfrac(f2);
cout<<endl;
cout<<"Operation entered is ";
cout<<op;
switch(op)
{
case '+':ans=add(f1,f2);break;
case '-':ans=sub(f1,f2);break;
case '*':ans=mul(f1,f2);break;
case '/':ans=div(f1,f2);break;
}
cout<<endl<<"Entered operation results in\n";
showfrac(ans);
}
fraction add(fraction& f1,fraction& f2)
{
fraction temp;
temp.num=((f1.num * f2.den) + (f2.num * f1.den));
temp.den=(f1.den * f2.den);
return temp;
}
fraction sub(fraction& f1,fraction& f2)
{
fraction temp;
temp.num=((f1.num * f2.den) - (f2.num * f1.den));
temp.den=(f1.den * f2.den);
return temp;
}
fraction mul(fraction& f1,fraction& f2)
{
fraction temp;
temp.num=f1.num * f2.num;
temp.den=f1.den * f2.den;
return temp;
}
fraction div(fraction& f1,fraction& f2)
{
fraction temp;
temp.num=f2.den;
temp.den=f2.num;
f2=temp;
temp.num=f1.num * f2.num;
temp.den=f1.den * f2.den;
return temp;
}
void getfrac(fraction& f)
{
cout<<"\nEnter numerator:";
cin>>f.num;
cout<<"\nEnter denominator:";
cin>>f.den;
}
void showfrac(fraction f)
{
cout<<f.num<<"/"<<f.den;
}
Jul 12, 2013 at 8:53pm UTC
Please use [co de][/code] tags.
main() should return an int.
Your showfrac() definition doesn't match the prototype (one has a reference, the other doesn't).
Jul 12, 2013 at 8:58pm UTC
oops blunder..got it...THANKS