未在此范围内声明

use*_*632 2 c++ scope

我收到错误信息

DataReader.h:13: error: 'String' was not declared in this scope
DataReader.cpp:5: error: redefinition of 'std::vector<Data*, std::allocator<Data*> > DataReader'
DataReader.h:13: error: 'std::vector<Data*, std::allocator<Data*> > DataReader' previously declared here
DataReader.cpp:5: error: 'String' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

这是我的cpp文件

#include "DataReader.h"

using namespace std;

vector<Data*> DataReader(String textFile) //line 5 that's giving error
{........}
Run Code Online (Sandbox Code Playgroud)

这是我的头文件

#include <fstream>
#include <iostream>
#include <vector>
#include <string>

#ifndef DATA_H
#define DATA_H
#include "Data.h"
#endif

std::vector<Data*> DataReader(String something);
Run Code Online (Sandbox Code Playgroud)

当我取出字符串参数并硬编码字符串的名称时,它们工作正常.但我需要多次使用此函数,并希望能够传入一个字符串作为参数.我传递的字符串是文本文件的名称.我错了吗?我似乎无法弄清楚..我的意思是什么意思'字符串'没有在这个范围内声明?我通过它,我包括在内.我的参数有问题吗?如果你能对这件事情有所了解,我们将不胜感激.

院长

Chr*_*ski 14

string应该是小写或std :: string