【发布时间】:2018-02-03 06:00:38
【问题描述】:
我正在从 Bjarne Stroustrup 的《编程:原则与实践》中学习 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";
}
当我在 Visual Studio 中键入相同的代码时,头文件“std_lib_facilities.h”出现错误。我糊涂了 用这个头文件。
还在用吗?我还能用什么来代替这个标题?
【问题讨论】:
-
这从来不常用。它是专门为那本书(或者更准确地说,是伴随它的课程)编写的。
-
我认为这可能是 this question 的副本,因为它在那里得到了回答,但是这两个问题有很大的不同,以至于我不愿意以具有约束力的投票结束,所以我会把链接留在这里。
-
那么,我应该如何阅读那本书?我应该修改代码吗?
-
@ArtemyVysotsky:
<string>是此"std_lib_facilities.h"间接包含的标头之一 -
如果错误是“std_lib_facilities.h”正在使用已弃用或过时的标头。您可能想在这里尝试更新版本github.com/BjarneStroustrup/…
标签: c++ visual-studio c++11