Another overloading "<<" problem

This is a discussion on Another overloading "<<" problem within the C++ Programming forums, part of the General Programming Boards category; My compiler told me what was wrong, doesn't yours do the same?...

  1. #16
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    My compiler told me what was wrong, doesn't yours do the same?

  2. #17
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    His did if you've read the first post carefully. He did not understand. Got it.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #18
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    elad: I did all that before I posted my thread. And with my original codes (all ofstream's, see posts above), this line gives the error:
    Code:
    ofstream &operator<<(ofstream& stream, const Student& s) {
         stream << s.getEnrollDate() << '|'    // error
    
         return stream;
    }
    And yup, I have succeded output member by member like this
    Code:
    stream << s.EnrollDate.month << '|'
                << s.EnrollDate.day << '|'
                << s.EnrollDate.year << '|'
    But, I thought since I overloaded "<<" for Date object, then I could utilize my first method.

    lyx: mine said
    E:\jDocument\CSCI\231\no1\Student.cpp(354) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'const class Date' (or there is no acceptable conversion)
    EDIT: I got the solution that I needed already, so thanks to all of you guys.
    PS. I promise I will give credit for you on my codes
    Last edited by alphaoide; 09-30-2003 at 10:00 AM.

  4. #19
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    In fact, it isn't what I mean, my compiler told me that it was an ostream and not a ofstream, so I understood.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. operator overloading slight problem
    By reddzer in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2006, 03:30 PM
  2. oops? not sure. operator overloading (possible) problem
    By w00tw00tkab00t in forum C++ Programming
    Replies: 8
    Last Post: 02-08-2006, 04:38 AM
  3. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  4. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM

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