C++ 什么';“这是怎么回事?”;库特;";及;提高;?

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

这是我第一次在我的机器上使用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;

  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;