Results 1 to 19 of 19

Thread: Weird thing while trying to avoid pointers in C++

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Weird thing while trying to avoid pointers in C++

    Quote Originally Posted by high_flyer View Post
    I am not sure even why this code compiles, since you are trying to assign c to t but you didn't define an '=' operator for your Node class.
    Qt Code:
    1. Node t = n.GetChild(n.GetCount() - 1); //I don't know why this compiles, it should not
    To copy to clipboard, switch view to plain text mode 
    This is equivalent to:
    Qt Code:
    1. Node t(n.GetChild(n.GetCount()-1));
    To copy to clipboard, switch view to plain text mode 
    The copy constructor kicks in here. Besides if you don't declare your own default constructor, copy constructor or assignment operator, the compiler will provide them for you.


    Quote Originally Posted by ct View Post
    Well it does take reference.

    Qt Code:
    1. void push_back ( const T& x );
    To copy to clipboard, switch view to plain text mode 
    No, it takes a const reference. That's two totally different things.
    Last edited by wysota; 14th February 2011 at 19:01.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. KDChart. What do you thing about?
    By Nadia in forum Qt-based Software
    Replies: 1
    Last Post: 15th February 2011, 01:55
  2. doing a thing after the form is displayed
    By franco.amato in forum Newbie
    Replies: 3
    Last Post: 26th January 2011, 05:05
  3. Very strange thing
    By Sheng in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2008, 22:44
  4. There is QTimeEdit another thing in Qt4
    By Krishnacins in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2006, 16:06

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.