Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


A short program with faulty

  • Please log in to reply
No replies to this topic

#1 smilewithme


  • Members
  • 11 posts
  • Local time:11:09 PM

Posted 31 May 2005 - 08:02 PM

:thumbsup: My program has errors,but I don't know what's wrong with it.My teacher told us it could complete the convertions,however,it didn't work.Why?
The essential codes are here:
class rational
rational(double i):a(i),b(100){}
rational(int i,int j):a(i),b(j){}
void print(){cout<<a<<"/"<<b<<endl;}
operator double(){return(static_cast<double>(a)/:flowers:;}
double a,b;
int greater(int i,int j)
double greater(double x,double y)
rational greater(rational w,rational z)
int main()
{int i=12;
double y=1.56;
rational w(10),z(7.5);
cout<<greater(w,z); //right
cout<<greater(w,y); //right
cout<<greater(y,w); //error:3 overloads have similar convertions.
cout<<greater(i,w); //error:3 overloads have similar convertions.

Edited by smilewithme, 31 May 2005 - 08:03 PM.

BC AdBot (Login to Remove)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users