【发布时间】:2013-05-08 15:22:33
【问题描述】:
我需要实现一个支持运算符
这里是头文件:
数字.h
#ifndef NUMBER_H
#define NUMBER_H
#include <iostream>
class Number{
public:
//an output method (for all type inheritance from number):
virtual void show()=0;
//an output operator:
friend ostream& operator << (ostream &os, const Number &f);
};
#endif
为什么编译器无法识别友元函数中的ostream?
【问题讨论】:
-
因为与所有标准库类型和函数一样,只有 没有
ostream。只有std::ostream。
标签: c++ compiler-errors operators ostream