Overloading << and >>

This is a discussion on Overloading << and >> within the C++ Programming forums, part of the General Programming Boards category; Please tell me why my input and output are not the same in this code. cents is always zero and ...

  1. #1
    MMu
    MMu is offline
    Registered User
    Join Date
    Mar 2008
    Posts
    4

    Question Overloading << and >>

    Please tell me why my input and output are not the same in this code.
    cents is always zero and the symbol is not defined!
    Attached Files Attached Files

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    It can't parse the separating dot. You need to read it into a dummy char.

    By the way, you're using the pre-standard headers. See the FAQ for why you should use <iostream> instead of <iostream.h>, and what else you need to change as a consequence.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overloading fstream's << and >> operators
    By VirtualAce in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2007, 04:17 AM
  2. Overloading << and >>
    By Enahs in forum C++ Programming
    Replies: 2
    Last Post: 09-15-2005, 05:33 PM
  3. << and >> overloading
    By Armatura in forum C++ Programming
    Replies: 2
    Last Post: 12-07-2003, 06:19 PM
  4. Overloading the << and >> operators
    By WebmasterMattD in forum C++ Programming
    Replies: 9
    Last Post: 10-15-2002, 06:22 PM
  5. istream >> overloading
    By wazza13 in forum C++ Programming
    Replies: 1
    Last Post: 05-03-2002, 11:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21