use*_*632 4 c++ constructor destructor
我遇到了语法/解析错误,但我似乎找不到它.
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..
Run Code Online (Sandbox Code Playgroud)
这是.cpp文件:
#include "DataReader.h"
using namespace std;
vector<Data*> DataReader()
{
.....
}
Run Code Online (Sandbox Code Playgroud)
我跳过了DataReader()的内容,因为我认为它无关紧要,但我可以根据需要发布它.
感谢您的任何意见/建议.
在头文件中,您需要显式使用std::vector而不是仅使用vector.
另外,我猜测"Data.h"包含以下形式的语句:
#ifndef DATA_H
#define DATA_H
...
#endif
Run Code Online (Sandbox Code Playgroud)
这没关系,但你不应该使用这些包括防护#include "Data.h",只在文件本身内.