No function prototypes with a string argument?

I am writing a program and trying to create a prototype of a function in a header file. Here is what I have:

Header:
1
2
3
4
5
6
7
8
#include <string>

#ifndef Func_H
#define Func_H

void testFunc(string arg1);

#endif 

Cpp:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <string>
#include "Func.h"
using namespace std;

void testFunc(string arg1)
{
	cout << arg1;
}


But that returns an error when building a solution. However, if replace string arg1 with int arg1 or any other data type that isn't string, then it works fine.

Basically, in my Main.cpp, I want to call a function with a string parameter, that is in another .cpp file. My first idea was to use header files, and references to function prototypes and all that. If there is a better way to do this, then please let me know. I'm very new to C++.
Because to properly use a C++ string (which you're trying to do) you must use std::string arg1 The reason being is that your header file doesn't use the std namespace so the compiler has no idea what a string is.
Topic archived. No new replies allowed.