我有一个 hello world c++ 文件,编译时出现一些错误。似乎 c++ 设置出了问题。以下是我得到的结果:
root@localhost:/home/student/tmp/gios/pr4/part1# g++ -o hello example.cpp
In file included from /usr/include/c++/7/ext/string_conversions.h:43:0,
from /usr/include/c++/7/bits/basic_string.h:6361,
from /usr/include/c++/7/string:52,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from example.cpp:1:
/usr/include/c++/7/cstdio:133:11: error: '::rewind' has not been declared
using ::rewind;
该文件有以下内容:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!";
return 0;
}
g++版本:
root@localhost:/home/student/tmp/gios/pr4/part1# g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
清除后我重新安装,build-essentials
但没有任何效果。我得到了和之前一样的错误。我应该做些什么来设置头文件吗?
谢谢。