PDA

View Full Version : Can you have a member function returning a string in a class?



ayanda83
10th July 2012, 17:27
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?

mvuori
10th July 2012, 17:38
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.

ChrisW67
11th July 2012, 00:18
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.