//using namespace std;
using std::ifstream;
using std::ofstream;
using std::cout;
class Dog
{
friend ostream& operator<< (ostream&, const Dog&);
public:
char* name;
char* breed;
char* gender;
Dog();
~Dog();
};
<<演算子をオーバーロードしようとしています。私も良いコーディングを練習しようとしています。しかし、using名前空間stdのコメントを外さない限り、私のコードはコンパイルされません。私はこのエラーを受け取り続けます、そして私は知りません。g++コンパイラを使用しています。
Dog.h:20: error: ISO C++ forbids declaration of ‘ostream’ with no type
Dog.h:20: error: ‘ostream’ is neither function nor member function; cannot be declared friend. if i add line using std::cout; then i get this error.
Dog.h:21: error: ISO C++ forbids declaration of ‘ostream’ with no type.
名前空間stdを使用せずに<<演算子をオーバーロードする正しい方法を誰かに教えてもらえますか?