仍然使用c ++ std_lib_facilities.h吗?

r0g*_*gue 5 c++ visual-studio c++11

我正在从编程原理和实践中学习C ++。他们给出了一个示例程序:

// read and write a first name
#include "std_lib_facilities.h"
int main()
{
    cout << "Please enter your first name (followed by 'enter'):\n";
    string first_name; // first_name is a variable of type string
    cin >> first_name; // read characters into first_name
    cout << "Hello, " << first_name << "!\n";
}
Run Code Online (Sandbox Code Playgroud)

如果在Visual Studio中输入相同的类型,则会为头文件提供错误。我对此头文件感到困惑。

还在用吗?除了该标题,我还能使用什么?

小智 4

在《编程:使用 C++ 的原理与实践》一书的附录(具体为 C.3.2)中,您实际上可以找到作者对这个特定头文件 - std_lib_facilities.h 的解释,并且他留下了一个链接供读者查看下载(http://www.stroustrup.com/Programming/std_lib_facilities.h)。

由于学习者必须下载该文件并将其放置在您选择的目录中,因此我从这一点推断该文件不是人们实际使用的头文件,而仅用于教学用途。

  • 书中确实给出了这个链接,但它指向旧版本的 std_lib_facilitied.h,这可能会给出错误消息。最新版本可以在 [http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h](http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h) 或 githuspage 上找到用户 Jon 在 OP 下的评论中提到。另请参阅此相关[问题](/sf/ask/3591950491/) (4认同)
  • @Ernie060 你的链接似乎不起作用。您的评论只有 1.5 个月。也许最近发生了一些变化。 (2认同)
  • @MarkMiller 感谢您指出这一点。我相信这个链接是有效的,因为我在阅读原则和实践书籍时尝试过它。似乎整个部分 [www.stroustrup.com/Programming](https://www.stroustrup.com/Programming) 不再起作用......然后应该查阅乔恩提到的 gibhub 页面。 (2认同)