im currently studing c++ in collage, and am having a huge issue with my current homework. the assignment is to take a input of two fractions and the programing knowing from the input whether to add, subtract, multiply or divide the fractions, and display the result as a fraction using two routines called getfrac and read frac. here is what i have so far and the associated errors ir anyone can help?
//fraction.cpp
//this program reads a fraction, and then calls a function to do math with it
------ Build started: Project: fraction, Configuration: Debug Win32 ------
Compiling...
fraction.cpp
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(930) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(930) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(930) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(930) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(923) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(923) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(923) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(923) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(916) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(916) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(916) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(916) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(909) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(909) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(909) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(909) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(871) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(785) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(785) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(738) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(738) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(738) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(738) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits>
&std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(700) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(700) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(700) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(700) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(653) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(653) : see declaration of 'std::operator <<'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(871) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(871) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(871) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(825) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(825) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(825) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits>
&std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(825) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(785) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(785) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::istream'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(653) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::istream'
c:\program files\microsoft visual studio 9.0\vc\include\ostream(653) : see declaration of 'std::operator <<'
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(24) : error C2676: binary '<<' : 'std::istream' does not define this operator or a conversion to a type acceptable to the predefined operator
Build log was saved at "file://c:\Documents and Settings\alissa\My Documents\Visual Studio 2008\Projects\fraction\fraction\Debug\BuildLog.htm"
fraction - 41 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
nice catch on the cin, that took care of almost all of the errors, and now all that is showing is
fraction.obj : error LNK2019: unresolved external symbol "void __cdecl getfrac(int &,int &)" (?getfrac@@YAXAAH0@Z) referenced in function "void __cdecl readfrac(int &,int &,int &,int &,char &)" (?readfrac@@YAXAAH000AAD@Z)
C:\Documents and Settings\alissa\My Documents\Visual Studio 2008\Projects\fraction\Debug\fraction.exe : fatal error LNK1120: 1 unresolved externals
im assuming this has to do with the readfrac call issue, and am confused as to what i need to add thier to fix this
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(23) : error C2660: 'getfrac' : function does not take 2 arguments
c:\documents and settings\alissa\my documents\visual studio 2008\projects\fraction\fraction\fraction.cpp(25) : error C2660: 'getfrac' : function does not take 2 arguments
You haven't done anything to fix the problem. You need to make your getfrac() prototype match the function declaration. And you need to call it with the amount of parameters it is supposed to take.
Maybe it would be easier if you explained what you were trying to do.
i have to use the functions getfrac and readfrac to input two fractions, as a math problem, for example, 3/4 + 5/6, or 1/2 * 1/4 and it output the result, in fraction form, and it be able to automatically pick up the correct mathmatical equation, i.e. 1/2 * 1/4 would be the input, and the out put would end up being 1/8, or if trying to add 3/4 and 5/6, it figure out the sum of that and output it as 38/24
getfrac () gets the fractions, and readfrac() figures out the correct mathmatical equation to do, so that i can write later functions to actually do the math
in other words, rather then selecting it from a menu, it needs to take the input as 3/4 + 1/2, and know that the two fractions are 3/4 and 1/2, and to add them, vice inputting 3/4 and 1/2, and selecting from a menu whether to add subtract multiply or divide
to quote the book - write a function that reads a problem involving two common fractions such as 2/4 + 5/6. after reading the common fractions problem call a function to perform the indicated operation ( call addfrac for +, multiply frac for *, etc....) and pass the numerator and denomanator of both fractions to the functiom that performs the operation. the function should return the num and denom of the result as its output parameters use functions readfracproblem and getfrac from listings 6.3 and 6.4
the original ger fra was
#include <iostream>
using namespace std;
void getfrac (int&, int&);
int main ()
{
int num, denom;
cout <<" enter a common fraction as 2 integers seperated by a slash";
getfrac (num, denom);
cout <<" fraction is " << num << " / " << denom << endl;
It seems what they want you to do is use readfracproblem() to get the data the user inputs, then call another function to add, subtract etc based on the data you received, then simplify the fraction.
Think about how to do that then post if you have any problems.