Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm running into a syntax/parsing error, but I can't seem to locate it.

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

Here is 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 content of DataReader() because I think it's irrelevant, but I can post it if needed.

Thanks for any input/suggestions.

like image 305
user200632 Avatar asked Dec 07 '22 05:12

user200632


1 Answers

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

Also, I'm guessing that "Data.h" contains statements of the form:

#ifndef DATA_H
#define DATA_H
...
#endif

That's fine, but you should not use these include guards across #include "Data.h" as well, only within the file itself.

like image 200
user200783 Avatar answered May 19 '23 19:05

user200783