C ++标头 [英] C++ headers

查看:68
本文介绍了C ++标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我正在尝试使用STL字符串类(STL的新功能),但不是很多运气。仅供参考,我在Linux 2.6上使用g ++。我按照说明包含了

标题:


#include< string>


但我收到错误消息:


错误:`string''没有命名类型


我查看了我的''/ usr / include''目录并且没有找到名为

''string''的文件。文件''string.h''当然指向基本字符串

函数。


我错过了STL标题吗?


如果是这样,为什么编译器没有对我大喊它无法找到

文件?


或者我是不是做了些蠢事?


先谢谢了,伙计们。

解决方案

kramer31写道:


嗨。我正在尝试使用STL字符串类(STL的新功能),但不是很多运气。仅供参考,我在Linux 2.6上使用g ++。我按照说明包含了

标题:


#include< string>


但我收到错误消息:


错误:`string''没有命名类型


我查看了我的''/ usr / include''目录并且没有找到名为

''string''的文件。文件''string.h''当然指向基本字符串

函数。



怎么样/ usr / include / c ++ / * /?


我错过了STL标题?



可能不是。在任何情况下,标准头文件都不需要是实际的

文件。


如果是这样的话为什么编译器没有对我大喊,它找不到

文件?



确实找到了该文件。否则它会说''字符串:没有

这样的文件或目录''。


或者我是jsut做了一些愚蠢的事情?



我的猜测是你在

代码中只使用''string''代替''std :: string'',但是没有任何代码就很难说。


-

rbh


那么/ usr / include / c ++ / * /?


不存在。


>


我错过了STL标题吗?



可能不是。无论如何,标准标题不需要是实际的

文件。


我的猜测是你在
$ b中只使用''string''代替''std :: string'' $ b代码,但没有任何代码很难说。



你是对的,先生!我做了。


不过,我不介意找到那个标题的位置......(我猜

我只是好奇) 。我更习惯于c样式标题,其中文件的实际名称在#include指令中。

预处理器如何知道如何找到< string>?


无论如何,谢谢你的帮助。


kramer31写道:


>嗨。我正在尝试使用STL字符串类(STL的新功能),但不是很幸运。仅供参考,我在Linux 2.6上使用g ++。我按照说明包含了
标题:

#include< string>

但是我收到错误消息:

错误: `string''没有命名类型
...



尝试:


#include< string>

...

std :: string some_string;





#include< string>

...

使用命名空间std;

...

string some_string;

Roberto Waltman


[请回复群组,

返回地址无效]


Hi. I''m trying to use the STL string class (new to STL), but not
having much luck. FYI, I''m using g++ on Linux 2.6. I included the
header as instructed:

#include <string>

But I get the error message:

error: `string'' does not name a type

I looked at my ''/usr/include'' directory and found no file called
''string''. The file ''string.h'' of course points to the basic string
functions.

Am I missing the STL headers?

If so why didn''t the compiler yell at me that it couldn''t find the
file?

Or did I jsut do something stupid?

Thanks in advance, guys.

解决方案

kramer31 wrote:

Hi. I''m trying to use the STL string class (new to STL), but not
having much luck. FYI, I''m using g++ on Linux 2.6. I included the
header as instructed:

#include <string>

But I get the error message:

error: `string'' does not name a type

I looked at my ''/usr/include'' directory and found no file called
''string''. The file ''string.h'' of course points to the basic string
functions.

What about /usr/include/c++/*/ ?

Am I missing the STL headers?

Probably not. In any case, the standard headers don''t need to be actual
files.

If so why didn''t the compiler yell at me that it couldn''t find the
file?

It did find the file. Else it would have said something like ''string: No
such file or directory''.

Or did I jsut do something stupid?

My guess is that you used only ''string'' instead of ''std::string'' in your
code, but it''s hard to say without any code.

--
rbh


What about /usr/include/c++/*/ ?

Non-existent.

>

Am I missing the STL headers?


Probably not. In any case, the standard headers don''t need to be actual
files.

My guess is that you used only ''string'' instead of ''std::string'' in your
code, but it''s hard to say without any code.

You are correct, sir! I did.

Still, I wouldn''t mind finding out where that header is... (I guess
I''m just curious). I''m more used to c style headers where the actual
name of the file is in the #include directive. How do the
preprocessor know how to find <string>?

Anyway, thanks for your help.


kramer31 wrote:

>Hi. I''m trying to use the STL string class (new to STL), but not
having much luck. FYI, I''m using g++ on Linux 2.6. I included the
header as instructed:

#include <string>

But I get the error message:

error: `string'' does not name a type
...

Try:

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

or

#include <string>
...
using namespace std;
...
string some_string;
Roberto Waltman

[ Please reply to the group,
return address is invalid ]


这篇关于C ++标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆