我需要實現一個數字類,支持運算符< <輸出。 我有一個錯誤:「標識符‘ostream的一些原因eventhough我列入’未定義」,並嘗試也標識符「ostream」未定義錯誤
這裏的頭文件:
Number.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'。 – 2013-05-14 11:42:33