包括字符串,字符串不会命名一个类型
问题描述:
我已经包含字符串,并且刚刚在头文件中的结构中调用字符串变量之后。 我得到“字符串没有指定类型”它包括字符串,字符串不会命名一个类型
//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
也许我问之前,尽管呼吁字符串字符串始发地和目的地城市,我究竟做错了什么?
答
它被称为std::string
,除非你在using
指令(你不应该在标题中)。
嗯,是的...我试过string :: string,而不是工作。谢谢。我忘了它是在std。 – Athetius 2011-03-27 22:15:40