я не уверен, почему у меня проблемы с ostream. Если я использую, используя пространство имен std; он выдает больше ошибок, таких как ошибки компоновщика.
Это мой код, где у меня возникают проблемы и ошибки.
virtual void Put (ostream&) const;
error C2061: syntax error : identifier 'ostream'
error C2065: 'ostream' : undeclared identifier
error C2059: syntax error : ')'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
error C2061: syntax error : identifier 'ostream'
error C2061: syntax error : identifier 'ostream'
это заголовочный файл контейнера .h, где у меня проблемы с
#ifndef CONTAINER_H
#define CONTAINER_H
#include <ostream>
#include <iostream>
#include "Object.h"
#include "NullObject.h"
#include "Ownership.h"
#include "Iterator.h"
#include "Visitor.h"
class Container : public virtual Object, public virtual Ownership
{
protected:
unsigned int count;
Container ();
public:
virtual unsigned int Count () const;
virtual bool IsEmpty () const;
virtual bool IsFull () const;
// virtual HashValue Hash () const;
virtual void Put (ostream&) const;
virtual Iterator& NewIterator () const;
virtual void Purge () = 0;
virtual void Accept (Visitor&) const = 0;
};
#endif
если я использую
virtual void Put (std::ostream&) const;
исправляет ошибки, однако в исходящем файле .cpp я получаю те же ошибки, что и выше, в функции put. я попробовал std :: in put, но он выкинул кучу ошибок компоновщика. я пытался использовать пространство имен std; также, но это бросает тонну ошибок компоновщика.
#include "Container.h"
#include "NullIterator.h"
#include <ostream>
#include <iostream>
Container::Container () :
count (0)
{}
unsigned int Container::Count () const
{ return count; }
bool Container::IsEmpty () const
{ return Count () == 0; }
bool Container::IsFull () const
{ return false; }
Iterator& Container::NewIterator () const
{ return *new NullIterator (); }
void Container::Put(ostream&)const
{
return;
}
вот ошибки, которые я теперь получаю в этом файле container.cpp
error C2065: 'ostream' : undeclared identifier
error C2059: syntax error : ')'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
я пытался включить fstream
Я буду признателен за любую помощь здесь. Theres тонна больше кода, но я не думаю, что вам нужно видеть другие файлы.