"Expected constructor, destructor, or type conversion before" <token "

I encountered a syntax / parsing error, but I can not find it.

DataReader.h: 11: error: expected constructor, destructor, or type conversion to '<' Marker

Here is the 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..

And this is the .cpp file:

#include "DataReader.h"

using namespace std;

vector<Data*> DataReader()
{
 .....
}

I skipped the contents of DataReader () because I think it doesn't matter, but I can post it if necessary.

Thanks for any input / suggestions.

+3
source share
4 answers

In your header file you need to explicitly use std::vector, not just vector.

, , "Data.h" :

#ifndef DATA_H
#define DATA_H
...
#endif

, , #include "Data.h", .

+5

std::vector vector DataReader.

<vector> vector, std, using namespace std; using std::vector;.

+4

I think that in your title you probably need to write std::vector<Data*> DataReader();because using namespace std;it is not in scope.

+4
source

Use std: vector, not the vector before Datareader.

+1
source

Source: https://habr.com/ru/post/1721670/


All Articles