Error that shouldnt be showing up

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

// Includes
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;

// Main Function
void main(int argc, _TCHAR* argv[])
{
	string word;

	cout << "This is a echo program.\n\n";

	cout << "Enter your word: ";
	cin >> word;

	echo(word);
}
//Echo Function
void echo(const string message)
{
	cout << message << endl;
}


For some reason why the error message is showing that at line 16 cin >> word;, and in the echo function line 23 cout <<, its telling me that those operators are not matching anything in iosteam and its only those 2 lines.
Last edited on
Main doesn't return void, it returns an int. Do either of these:

1
2
3
4
main(int argc, _TCHAR* argv[]) {
//your code

}

This is the implicit example.

The other more traditional way is:
1
2
3
4
5
int main(int argc, _TCHAR* argv[]) {

//your code
return 0;
}


HTH


Edit:

You can also leave out the argc & argv parameters if you don't need them.
Last edited on
Try to include header <string>.
Topic archived. No new replies allowed.