【发布时间】:2009-11-02 12:25:01
【问题描述】:
我收到一条错误消息
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
这是我的 cpp 文件
#include "DataReader.h"
using namespace std;
vector<Data*> DataReader(String textFile) //line 5 that's giving error
{........}
这是我的头文件
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#ifndef DATA_H
#define DATA_H
#include "Data.h"
#endif
std::vector<Data*> DataReader(String something);
当我取出字符串参数并对字符串的名称进行硬编码时,它们工作正常。但我需要多次使用这个函数,并且希望能够传入一个字符串作为参数。我传递的字符串是文本文件的名称。我在哪里弄错了吗?我似乎无法弄清楚..我的意思是“字符串”没有在这个范围内声明是什么意思?我正在通过它,我包括 .我的参数有问题??如果您能对此事有所了解,将不胜感激..
院长
【问题讨论】: