include string,string不命名类型

时间:2011-03-27 22:13:07

标签: c++ string include

我已经包含了字符串,并且只是在头文件中的结构中调用字符串变量之后。 尽管在字符串Origin和Destination City之前调用字符串

,但我得到'字符串不为字符串Origin和Destination City命名类型'
//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:错误:   'string'没有命名类型

     

sortedListClass.h:11:5:错误:   'string'没有命名类型

我可能会问我做错了什么?

1 个答案:

答案 0 :(得分:7)

除非您输入std::string指令(不应在标题中执行),否则称为using