出力のためにオペレータ< <をサポートする番号クラスを実装する必要があります。 私はエラーを持っている:「識別子 『のostreamは、』未定義である」いくつかの理由から、ヘッダファイル本家の私は含まれており、ここにも識別子 "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を認識できますか?
std::ostream
// ^^^^^
だからあなたのオペレータの宣言になるはずです::
またfriend std::ostream& operator << (std::ostream &os, const Number &f);
// ^^^^^ ^^^^^
、あなたが持っている可能性がありますが、完全にクラスの生活は、名前空間の名前で名前ostream
を修飾する必要が
すべての標準ライブラリタイプおよび関数と同様に、*は* ostreamではないためです。 'std :: ostream'しかありません。 –