4
#ifndef STRCUTS_H
#define STRCUTS_H
#include <string>

struct menuEntry 
{ 
    string itemID;    //'string' does not name a type
    string itemName;  //'string' does not name a type
};

#endif

I get the same error when I put #include < string> above the header guard. Come to think of it, I've had weird trouble with putting struct definitions in headers before. Must be something I'm not getting.

1 Answer 1

7

You need to change string to std::string, i.e.

#ifndef STRCUTS_H
#define STRCUTS_H

#include <string>

struct menuEntry 
{ 
    std::string itemID;
    std::string itemName;
};

#endif
Sign up to request clarification or add additional context in comments.

2 Comments

or add a using std::string or using namespace std. Just FYI.
@KitsuneYMG: no - you should never put using namespace std (or using namespace <anything> in a header.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.