Results 1 to 3 of 3

Thread: Can you have a member function returning a string in a class?

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Red face Can you have a member function returning a string in a class?

    Hi everyone, is it possible to have a member function that returns a string in a class. I'm new in Qt and I've written this class which contains one of the member functions with "string" as a return type but when I run a program with this class, I get an error "string does not name a type". why is this?

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Can you have a member function returning a string in a class?

    A member function can return anything you wish, including a "string", if there is such type or class in the scope of the class.

    It does not make any sense to try to guess what an error message means without seeing the code. And it does not make any sense to ask what an error message means without posting some code.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can you have a member function returning a string in a class?

    The error message means that "string", whatever type that is, has not been declared before use. Usually this is a missing #include or scope issue.

Similar Threads

  1. Replies: 13
    Last Post: 27th August 2014, 11:06
  2. Replies: 2
    Last Post: 28th March 2012, 21:47
  3. Replies: 2
    Last Post: 23rd February 2012, 12:23
  4. Replies: 4
    Last Post: 7th June 2011, 00:46
  5. returning a string
    By mickey in forum General Programming
    Replies: 2
    Last Post: 3rd February 2008, 19:41

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.