return is empty


The following code compilies correctly, but does not reurn the string. Seems to be empty.

Probably something obvious, but I can't see it.

Please can anyone help. Thank you.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
using std::string;

int _tmain(int argc, _TCHAR* argv[])

{
string bigstring; string strFunct;

bigstring = strFunct;
					
cout << bigstring << endl;


cout << "Done\n";
 system("pause");

	return 0;
}


  string strFunct()
{
   return "ooooooooooooooooooo";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//using std::string;

int _tmain(int argc, _TCHAR* argv[])

{
string bigstring;// string strFunct;

bigstring = strFunct();
					
cout << bigstring << endl;


cout << "Done\n";
 system("pause");

	return 0;
}


  string strFunct()
{
   return "ooooooooooooooooooo";
}
I have the following error when I try that Breadman:

error C2065: 'strFunct' : undeclared identifier
In C++, the compiler must know about a function before you use it. In your code, you are trying to use the function strFunct before you have told the compiler about it.

There are two ways you can tell the compiler about it.

1) Declare the function, using a prototype:
string strFunct();

2) Put the whole definition of the function before the main function.
Thats it. Working now.

Thanks for help, and quick responses Breadman and Moschops.
Topic archived. No new replies allowed.