c++库重构编译器错误
c++ library refrencing compiler error
这是一个简单的问题,但我似乎找不到问题
#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
};
}
在这里,我在头文件中定义了一个类
但是它抛出了一个编译器错误,说它找不到对ostream 的引用
stl中的类位于命名空间std.中
因此,除非您正在执行using namespace std
,否则必须在它们前面加上std::
。在您的情况下,您应该编写std::ostream
。
您缺少ostream前面的std::
。
您可以:
-
在类定义之前使用整个名称空间:
using namespace std;
; -
标记您将使用std::ostream:
using namespace std::ostream;
; -
或者在任何需要使用的地方编写
std::ostream
。
您也可以在调用ostream
之前添加using namespace std
相关文章:
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++,我收到一个无法理解的编译器错误
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- C++错误C2600:无法定义编译器生成的特殊成员函数(必须首先在类中声明)
- 我收到同义重复编译器错误。我应该如何修复"类型"X"的参数与类型"X"的参数不兼容?
- 重载方法的方式会在使用临时调用时生成编译器错误
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- 有没有办法让编译器在我放置字符串而不是 nlohmann::json 对象时抛出错误?
- 致命错误 C1001 :vs2017 15.8.4 的内部错误(编译器文件"msc1.cpp",第
- C++2440错误-编译器认为字符串是常量字符
- Clang 错误 – 编译器错误或缺少一些细节?
- 视觉C++ 2017 错误?编译器优化表达式
- 配置:错误:C++编译器无法创建可执行文件
- PHP PDO_ODBC配置:错误:C 编译器无法创建可执行文件
- 致命错误 C1001:内部编译器错误(编译器文件"MSC1.cpp",第 1794 行)
- 错误:编译器限制达到简单hello world程序的堆限制
- c++链接错误:编译器找不到函数的定义
- 生成 CImg 时出现致命错误(编译器限制)
- 抛出对齐类型时出现 Clang 运行时错误.编译器错误