c ++库refrencing编译器错误

Bil*_*nks 0 c++ compiler-errors

这是一个简单的问题,但我似乎无法找到问题

    #include <iostream>
namespace utils {
    class IntList {
      public:
        IntList();                         // constructor; initialize the list to be empty
        void AddToEnd(int k);              // add k to the end of the list
        void Print(ostream &output); // print the list to output

      private:
        static const int SIZE = 10;      // initial size of the array
        int *Items;                      // Items will point to the dynamically allocated array
        int numItems;                    // number of items currently in the list
        int arraySize;                   // the current size of the array
    };
}
Run Code Online (Sandbox Code Playgroud)

这里我在头文件中定义了一个类

但它抛出一个编译器错误,说它无法找到对ostream的引用

Mes*_*sop 5

stl中的类位于命名空间std中.

所以,除非你这样做,否则你using namespace std必须为它们添加前缀std::.在你的情况下,你应该写作std::ostream.