Advertisement
Felanpro

string return

Apr 23rd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. //I was just playing around with c++ and tried to return a string in a function. This is the way I did it!
  2. //Also do you recognize that you don't need the #include <string>? <iostream> is nice and includes strings aswell.
  3. //But it's always important and necessary to #include <string> when you're using the string data type!!!(WARNING!)
  4.  
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. string helloworld(string text)
  10. {
  11.     return text;
  12. }
  13.  
  14. int main()
  15. {
  16.     string function1 = helloworld("Hello World!");
  17.     cout << function1 << endl;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement