error msg

This is a discussion on error msg within the C++ Programming forums, part of the General Programming Boards category; I am getting the following error msg: Code: Type mismatch in redeclaration of 'operator <<(ostream &,const String &)' This is ...

  1. #1
    Unregistered
    Guest

    error msg

    I am getting the following error msg:
    Code:
    Type mismatch in redeclaration of 'operator <<(ostream &,const String &)'
    This is the code that relates to it :
    Code:
    //this is in the struct
    friend ostream& operator <<( ostream& out, const String& wrd);
    
    //this is the fnct
    ostream& operator <<( ostream& out, const String& wrd)
    {
       out << wrd.str;
       return out;
    }
    Thanx

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    Ok, yes I edited my entire message, that's because I'm a moron. The reason your getting the message is because ( at least it seems) that you are passing either a struct or class as a argument yet you overloaded the operator telling it you are passing a String reference. Here is the solution:
    Code:
                friend ostream& operator<<(ostream&, class& );
    just replace class with whatever name you gave your class or struct.
    Last edited by Traveller; 05-26-2002 at 03:27 AM.

Popular pages Recent additions subscribe to a feed

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