Results 1 to 5 of 5

Thread: skip function parameter

  1. #1
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default skip function parameter

    Hello,
    if i have a function like this:

    bool funz ( QString name , QString * lastname );

    sometime i need to skip lastname parameter, what should i declere it?
    I usually do in this way when i dont have to handle pointer:

    bool funz ( QString name , QString lastname = "" );

    I tried to do in this way:

    bool funz ( QString name , QString * lastname = NULL );

    but it doesn't work....
    thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: skip function parameter

    What does "doesn't work" mean? A compiler error? If so, paste it.
    J-P Nurmi

  3. #3
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: skip function parameter

    my function in .h file:
    Qt Code:
    1. bool funz( twmConfigTerminalItemStruct* twmConfigTerminalItem , QString theIPAddress = "" , QString * stringToReturn = NULL );
    To copy to clipboard, switch view to plain text mode 

    my function in .cpp file:
    Qt Code:
    1. bool twmCommunicationObject::funz ( twmConfigTerminalItemStruct* twmConfigTerminalItem , QString theIPAddress , QString * stringToReturn )
    To copy to clipboard, switch view to plain text mode 

    i call it in my Main in this way:
    Qt Code:
    1. funz ( twmConfigTerminalItemStruct* twmConfigTerminalItem )
    To copy to clipboard, switch view to plain text mode 
    and i get a segmentation fault...

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: skip function parameter

    Perhaps you're missing a sufficient check for null pointer?
    Qt Code:
    1. if (stringToReturn != NULL)
    2. {
    3. *stringToReturn = "foo";
    4. }
    To copy to clipboard, switch view to plain text mode 
    I'm sorry I'm afraid there's not much we can say about it with that amount of information. Just compile the app in debug mode and run it via gdb whenever you get such crashes you don't understand.
    J-P Nurmi

  5. #5
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: skip function parameter

    it doen't work....but i solved it using overloading
    thx

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 00:41
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

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.