开发者

include string, string doesn't name a type

开发者 https://www.devze.com 2023-02-19 22:45 出处:网络
I have 开发者_如何学运维included string and just after call a string variable in a struct in an header file.

I have 开发者_如何学运维included string and just after call a string variable in a struct in an header file. I get the 'string doesn't name a type' for string Origin and Destination City, despite calling string just before it

//sortedListClass.h (a few lines of comments)
#include <string>
struct flightRec{
    int flightnumber;
    string Origin; //problem #1
    string DestinationCity; // problem #2
    float cost;
    flightRec* ptr;
};
typedef flightRec* nodeptr;
#ifndef SORTEDLISTCLASS_H
#define SORTEDLISTCLASS_H
#include <iostream>
#include <cassert>

sortedListClass.h:10:5: error: ‘string’ does not name a type

sortedListClass.h:11:5: error: ‘string’ does not name a type

Might I ask what am I doing wrong?


It's called std::string unless you put in a using directive (which you shouldn't do in a header).

0

精彩评论

暂无评论...
验证码 换一张
取 消