Results 1 to 7 of 7

Thread: Operator overloading << error: must take exactly one argument

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    22
    Qt products
    Qt4

    Question Operator overloading << error: must take exactly one argument

    Hi all!

    I can't get my head around the compile error I get when overloading the << operator:
    error: ‘QDataStream& Coordinate:perator<<(QDataStream&, const Coordinate&)’ must take exactly one argument

    Here is the code:

    coordinate.h:
    Qt Code:
    1. class Coordinate
    2. {
    3. public:
    4. Coordinate();
    5.  
    6. double x, y, z;
    7.  
    8. // output
    9. QDataStream &operator <<(QDataStream& out, const Coordinate& c);
    10. };
    To copy to clipboard, switch view to plain text mode 
    coordinate.cpp:
    Qt Code:
    1. #include "coordinate.h"
    2.  
    3. Coordinate::Coordinate()
    4. {
    5. x = y = z = 0.;
    6. }
    7.  
    8. QDataStream& operator <<(QDataStream& out, const Coordinate& c)
    9. {
    10. out << "(" << c.x << ", " << c.y << ", " << c.z << ")";
    11. return out;
    12. }
    To copy to clipboard, switch view to plain text mode 

    What is wrong / am I not getting?

    Thanks!
    Last edited by nomiz; 11th March 2012 at 12:54.

Similar Threads

  1. Overloading QMap << operator
    By The 11th plague of Egypt in forum Newbie
    Replies: 3
    Last Post: 14th September 2011, 19:24
  2. Operator Overloading
    By naturalpsychic in forum Newbie
    Replies: 1
    Last Post: 19th July 2011, 05:19
  3. SOLVED: Operator overloading QDataStream
    By eekhoorn12 in forum Qt Programming
    Replies: 1
    Last Post: 9th May 2010, 23:55
  4. QList Overloading operator==()
    By josepvr in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2009, 15:28
  5. operator [] overloading
    By darksaga in forum General Programming
    Replies: 5
    Last Post: 8th April 2008, 15:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.