Results 1 to 20 of 66

Thread: Intro - Warning: BBBOORRRIINNGGG!!!!!

Hybrid View

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

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    I didn't say I didn't like it I used to draw the alphabet using the turtle BASIC was my first language, though... I have been learning it more than 15 years ago on my ATARI 65XE box.

    BASIC Code:
    1. 10 PRINT "Witek"
    2. 20 GOTO 10
    To copy to clipboard, switch view to plain text mode 


  2. #2
    Join Date
    Jan 2006
    Location
    Berlin, Germany
    Posts
    64
    Thanks
    1
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    I have actually never used logo at all...
    I did load up KTurtle one day but it looked too complicated so I didn't mess with it much lol

    const QString &signature = new QString("Katrina");

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by katrina
    const QString &signature = new QString("Katrina");
    Wow, two errors on one line! "new QString" returns QString* and not QString and you can't assign a newly created object to a reference -- a reference is just a "handler" for already existing objects. But besides that -- nice

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by wysota
    you can't assign a newly created object to a reference
    Qt Code:
    1. #include <iostream>
    2.  
    3. class Test {
    4. public:
    5. Test() {}
    6. int foo() const { return 1; }
    7. };
    8.  
    9. int main()
    10. {
    11. const Test& t = Test();
    12. std::cout << t.foo() << std::endl;
    13. return 0;
    14. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by jacek
    Qt Code:
    1. #include <iostream>
    2.  
    3. class Test {
    4. public:
    5. Test() {}
    6. int foo() const { return 1; }
    7. };
    8.  
    9. int main()
    10. {
    11. const Test& t = Test();
    12. std::cout << t.foo() << std::endl;
    13. return 0;
    14. }
    To copy to clipboard, switch view to plain text mode 
    Are you sure this is correct? You hold a reference to a temporary object here. The fact that it works in this case doesn't mean this is a correct statement.

    What if you store the reference to that object as a member of some class?

    Will compiler optimisations not affect the correctness of the above statement?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by wysota
    Are you sure this is correct? You hold a reference to a temporary object here.
    The secret lies in the "const" keyword.

  7. #7
    Join Date
    Jan 2006
    Location
    Shanghai, China
    Posts
    52
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by jacek
    The secret lies in the "const" keyword.
    yep, agree
    And it's pretty useful.

    Qt Code:
    1. void foo(const string & s); //no 'const' whill lead to error
    2. foo("abc");
    To copy to clipboard, switch view to plain text mode 
    1. Users don't have the manual, and if they did, they wouldn't read it.
    2. In fact, users can't read anything, and if they could, they wouldn't want to.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by bood
    yep, agree
    And it's pretty useful.

    Qt Code:
    1. void foo(const string & s); //no 'const' whill lead to error
    2. foo("abc");
    To copy to clipboard, switch view to plain text mode 
    In this case this is only because there is a cast defined from const char* to const string.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by wysota
    In this case this is only because there is a cast defined from const char* to const string.
    I wouldn't be so sure:
    Qt Code:
    1. #include <iostream>
    2. #include <string>
    3.  
    4. void foo( std::string& s )
    5. {
    6. std::cerr << s << std::endl;
    7. }
    8.  
    9. int main()
    10. {
    11. foo( std::string( "aaa" ) );
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

    $ g++ -Wall a.cpp
    a.cpp: In function `int main()':
    a.cpp:11: error: invalid initialization of non-const reference of type 'std::string&' from a temporary of type 'std::string'
    a.cpp:5: error: in passing argument 1 of `void foo(std::string&)'

  10. #10
    Join Date
    Jan 2006
    Location
    Berlin, Germany
    Posts
    64
    Thanks
    1
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Talking Re: Intro - Warning: BBBOORRRIINNGGG!!!!!

    Quote Originally Posted by wysota
    Wow, two errors on one line! "new QString" returns QString* and not QString and you can't assign a newly created object to a reference -- a reference is just a "handler" for already existing objects. But besides that -- nice
    LOL Hey, I was trying to be funny, not syntactically correct! LOL

    QShutTheHeckUp *;-) = new QShutTheHeckUp;

    (JUST KIDDING!)
    sorry couldn't help myself :-D

    Katrina

Similar Threads

  1. Visual Studio 2005 Express
    By Muzz in forum Installation and Deployment
    Replies: 22
    Last Post: 6th November 2008, 06:21
  2. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 05:34
  3. Crash handler on Win32
    By niko in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 19:41
  4. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 14:18
  5. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.