C ++ g ++ cannot find type 'string' in class header file

I am new to C ++, but cannot understand why this is not compiling for me. I work on Mac, coding Xcode, but I create my own makefile from bash.

In any case, I get two compiler errors that cannot be found in the "string" type, although I turned it on. Any help would be appreciated. The code:

//#include <string> // I've tried it here, too. I'm foggy on include semantics, but I think it should be safe inside the current preprocessor "branch"
#ifndef APPCONTROLLER_H
#define APPCONTROLLER_H

#include <string>
class AppController {
// etc.
public:
    int processInputEvents(string input); //error: ‘string’ has not been declared
    string prompt(); //error: ‘string’ does not name a type
};
#endif

I include this file in my main.cpp, and in another place I mainly use the type string, and it works fine. Although mostly I included iostreaminstead string(for other purposes). Yes, I also tried to include iostream in my AppController class, but it did not allow anything (I did not expect this either).

So I'm not quite sure what the problem is. Any ideas?

+5
1

std.

#include <string>
...
std::string myString;

using namespace std;

, , , . . , ( , ):

using std::string;

( ) , , .

+30

All Articles