gpt4 book ai didi

c++ - "Expected constructor, destructor, or type conversion before ' < ' token"

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:01:30 25 4
gpt4 key购买 nike

我遇到语法/解析错误,但我似乎找不到它。

DataReader.h:11: error: expected constructor, destructor, or type conversion before '<' token

这里是 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" 中使用这些包含防护,而只能在文件本身内使用。

关于c++ - "Expected constructor, destructor, or type conversion before ' < ' token",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1659932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com