Difference between cout and return!!

Pages: 12
The function will return a string and then within the main() function you will cout the function. And since the function returns the string, it will be displayed on the screen.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

string firstPresident();

int main()
{
	cout << firstPresident() << end << end;
	system("pause");  
}

string firstPresident()
{
	return "George Washington";
}


Cout just couts whatever string is returned by the firstPresident() function.
Topic archived. No new replies allowed.
Pages: 12