C++ 什么';“这是怎么回事?”;库特;";及;提高;?
这是我第一次在我的机器上使用boost——Ubuntu 12.04 amd64(带有g++4.6.3)。 资料来源如下:C++ 什么';“这是怎么回事?”;库特;";及;提高;?,c++,boost,C++,Boost,这是我第一次在我的机器上使用boost——Ubuntu 12.04 amd64(带有g++4.6.3)。 资料来源如下: #include <boost/timer.hpp> using namespace boost; int main() { timer t; cout << "max timespan: " << t.elapsed_max() / 3600 << "h" << endl; cou
#include <boost/timer.hpp>
using namespace boost;
int main()
{
timer t;
cout << "max timespan: "
<< t.elapsed_max() / 3600 << "h" << endl;
cout << "min timespan: "
<< t.elapsed_min() << "s" << endl;
cout << "now time elapsed:"
<< t.elapsed() << "s" << endl;
return 0;
然后我尝试将cout
和endl
更改为std::cout
和std::endl
,错误变成:
error: ‘cout’ is not a member of ‘std’
error: ‘endl’ is not a member of ‘std’
在文件顶部插入#包括
基本的东西真的你需要包括iostream
标题,并使用std::cout和std::endl
,就像它们在std
命名空间中定义的那样
#include <iostream>
std::cout << "max timespan: "
<< t.elapsed_max() / 3600 << "h" << std::endl;
#包括
std::cout在哪里声明了std::cout
和std::endl
以及std::cout等
#include <iostream>
std::cout << "max timespan: "
<< t.elapsed_max() / 3600 << "h" << std::endl;