![](/img/trans.png)
[英]expected constructor, destructor, or type conversion before ‘*’ token
[英]“Expected constructor, destructor, or type conversion before '<' token”
我遇到了语法/解析错误,但我似乎找不到它。
DataReader.h:11:错误:在'<'标记之前的预期构造函数,析构函数或类型转换
这是DataReader.h:
#include <fstream>
#include <iostream>
#include <vector>
#ifndef DATA_H
#define DATA_H
#include "Data.h"
#endif
vector<Data*> DataReader(); // This is line 11, where the error is..
这是.cpp文件:
#include "DataReader.h"
using namespace std;
vector<Data*> DataReader()
{
.....
}
我跳过了DataReader()的内容,因为我认为它无关紧要,但我可以根据需要发布它。
感谢您的任何意见/建议。
在头文件中,您需要显式使用std::vector
而不仅仅是vector
。
另外,我猜测“Data.h”包含以下形式的语句:
#ifndef DATA_H
#define DATA_H
...
#endif
这没关系,但你不应该在#include "Data.h"
使用这些包含警卫,只能在文件本身内使用。
在头文件中,您需要在函数DataReader
的声明中使用std::vector
而不是plain vector
。
标准include <vector>
导致vector
类模板在std
命名空间中定义,并且头文件中的声明在任何using namespace std;
之前发生using namespace std;
或者using std::vector;
。
我想在你的标题中你可能需要编写std::vector<Data*> DataReader();
作为using namespace std;
不在范围内。
在Datareader之前使用std:vector而不是vector。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.