Help with C++ Strings: Create a Class Function to Return a String

  • Context: Comp Sci 
  • Thread starter Thread starter SEGA
  • Start date Start date
  • Tags Tags
    C++ Strings
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
SEGA
Messages
2
Reaction score
0
I want to know, how to make a CLASS FUNCTION to return a STRING.
For example, taken that all variables are declared correctly.

string personType::get() const
{
return firstName + " " + lastName;
}
 
Physics news on Phys.org
To return a string, you just return a string. What is your real problem?
 
The compiler write error-type
 
There are many different types of "strings" possible in C++. Which one do you want to use?