Results 1 to 3 of 3

Thread: member

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default member

    hi, I need 2 members similar:
    Qt Code:
    1. void ob::Write(QTextStream& xstrm)
    2. void ob::Write(QTextStream& xstrm, QProgressDialog*)
    To copy to clipboard, switch view to plain text mode 
    but it contain 100 lines. Do I have to repeat the entire body of member twice? another way? thanks
    Regards

  2. #2
    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: member

    You can use the default value and implement only one of the methods:

    Qt Code:
    1. void ob::Write(QTextStream& xstrm, QProgressDialog *pd=0){
    2. if(pd==0){
    3. // no second parameter, act accordingly
    4. }
    5. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: member

    Either that, or you can place the code common to both functions in a third (private) function and call it from both. Personally, I prefer it that way.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

Similar Threads

  1. Replies: 5
    Last Post: 14th July 2006, 22:42
  2. error:invalid use of member
    By quickNitin in forum General Programming
    Replies: 4
    Last Post: 19th June 2006, 15:21
  3. emiting signals from const member functions !?
    By sunil.thaha in forum Qt Programming
    Replies: 2
    Last Post: 25th March 2006, 11:29
  4. Hey :: I am a new Member,
    By :db:sStrong in forum General Discussion
    Replies: 5
    Last Post: 18th February 2006, 20:01
  5. Replies: 5
    Last Post: 29th January 2006, 17:00

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.