user3083522
user3083522

Reputation: 211

String could not be resolved c++

I am wondering why I am getting error "string could not be resolved to type" when I have the proper inclusions?

#ifndef EVENTFILEREADER_H_
#define EVENTFILEREADER_H_
#include <string>
#include <stdlib.h>
#include <iostream>

class EventFileReader {
public:
    EventFileReader(string fileName);
    virtual ~EventFileReader();
};

#endif /* EVENTFILEREADER_H_ */

Upvotes: 0

Views: 209

Answers (2)

herohuyongtao
herohuyongtao

Reputation: 50667

Your compiler is complaining about not being able to find string as a defined type.

You should add its namespace std:

EventFileReader(std::string fileName);
                ^^^^^

Upvotes: 2

Spock77
Spock77

Reputation: 3325

You need to specify namespace, e.g.

std::string

or put the using declaration after includes:

using std::string;

Upvotes: 1

Related Questions