C++ std::basic_ostream没有合适的默认构造函数

C++ std::basic_ostream没有合适的默认构造函数,c++,visual-c++,C++,Visual C++,我在Visual Studio中尝试运行代码时遇到以下错误: 1>c:\users\pprasha1\documents\visual studio 2008\projects\simulated-anneal\simulated-anneal\erstream.hpp(120) : error C2512: 'std::basic_ostream<_Elem,_Traits>' : no appropriate default constructor available 1&

我在Visual Studio中尝试运行代码时遇到以下错误:

1>c:\users\pprasha1\documents\visual studio 2008\projects\simulated-anneal\simulated-anneal\erstream.hpp(120) : error C2512: 'std::basic_ostream<_Elem,_Traits>' : no appropriate default constructor available
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
以下是上下文的其余代码(搜索“Here”以查找行)

\ifndef-ERSTREAM\u水电站_
#定义ERSTREAM_水电站1.6
#包括
#包括
使用名称空间std;
#ifndef_uugnuc__
#ifndef继承错误BUF
#定义继承错误
#恩迪夫
#恩迪夫
#ifndef继承错误BUF
类错误流;
#恩迪夫
//错误处理程序的streambuf,不直接使用
类Errorbuf:公共流buf
{
私人:
#ifndef继承错误BUF
ErrorStream*ehp;//不属于Errorbuf!!!
#恩迪夫
字符*空间;
受保护的:
虚拟int-doallocate();
公众:
#ifdef继承_ERRORBUF
Errorbuf():空格(NULL){}
#否则
Errorbuf():ehp(NULL),空格(NULL){}
Errorbuf(ErrorStream*ehpl):ehp(ehpl),空格(NULL){}
#恩迪夫
~Errorbuf();
#ifndef继承错误BUF
无效关联(ErrorStream*ehpl){ehp=ehpl;}
虚拟整数溢出(整数c=EOF);
#恩迪夫
#ifdef__GNUC__
虚int underflow(){return EOF;}
#恩迪夫
虚拟整数同步();
};    
类错误流;
struct ErrManipRec//struct用于单参数操纵器
{ 
int-arg;
无效(*fp)(错误流和ehr,常数int a);
ErrManipRec(void(*f)(错误流和错误流,常数内部a),常数内部a)
:fp(f),arg(a){}
};
//实际的错误处理程序类
#ifdef继承_ERRORBUF
类ErrorStream:public Errorbuf、public ostream、virtual public ios
#否则
类错误流:公共ostream、虚拟公共ios
#恩迪夫
{
#ifndef继承错误BUF
友人艾尔布夫;
#恩迪夫
私人:
静态长整数;
静态长内弹力;
静态long int msgnum;//警告消息的计数
国际地位;
整数错误计数;
奥斯特拉姆和我的奥斯;
char*prog;
void nomore();
朋友无效警告(错误流和ehr、const int eval);
友元无效失败(错误流和ehr、常量内部评估);
friend void Fatal(错误流和ehr、常量内部评估);
受保护的:
虚拟整数写入(常量字符*s、常量整数len、常量整数eof);
#ifndef继承错误BUF
errorbuff buffer;
#恩迪夫
错误流(常量错误流和er);
公众:
ErrorStream(ostream&user_os=cerr):errcount(0),
#ifdef继承_ERRORBUF
ios((streambuf*)本),
#否则
ios(&buffer)、buffer((ErrorStream*)此、,
#恩迪夫
my_os(user_os)、prog(NULL)、errstatus(0){}//在此处
错误流(const char*s、ostream和user_os=cerr);
~ErrorStream();
#ifdef继承_ERRORBUF
虚拟整数溢出(整数c=EOF);
#否则
虚拟int sync(){return buffer.sync();}
#恩迪夫
无效关闭();
void reset(){errstatus=0;}
int status()常量{return errstatus;}
int count()常量{return errcount;}
静态无效第一条消息(const long int fmsg){efirst=fmsg-1;}
静态无效最大消息(const long int mxmsg){elast=mxmsg+1;}
//设置错误状态
ErrorStream和operator=(const int err);
//添加到错误状态
ErrorStream&运算符|=(常量int err);
//递增错误状态(递增前)
ErrorStream&运算符++()
{errstatus++;返回*this;}
#ifndef\uuuu附件2__
//递增错误状态(递增后)
#ifndef_uugnuc__
ErrorStream运算符++(int);//不适用于GCC
#恩迪夫
#恩迪夫
ErrorStream&operator+=(常数int公司)
{errstatus+=inc;返回*this;}
//写入错误消息的一种方法
无效警告(const char*msg=NULL);
void nonfatal(const char*msg=NULL){警告(msg);}
无效致命(常量字符*=NULL);
无效失败(const char*msg=NULL);
无效内存(const void*=NULL);
无效警告(const int eval,const char*msg=NULL);
无效非致命(常量int eval,常量char*msg=NULL)
{警告(eval,msg);}
无效致命(const int eval,const char*msg=NULL);
无效失败(const int eval,const char*msg=NULL);
无效内存(const int eval,const void*=NULL);
//ManInputator版本的致命和警告
friend ErrorStream&fatal(ErrorStream&er)
{er.fatal();返回er;}
好友错误流和警告(错误流和er)
{er.warning();返回er;}
朋友错误流和失败(错误流和er)
{er.fail();返回er;}
friend ErrManipRec致命(const int eval)
{返回ErrManipRec(::致命,eval);}
friend ErrManipRec警告(const int eval)
{返回ErrManipRec(::警告,eval);}
friend ErrManipRec失败(const int eval)
{返回ErrManipRec(::Fail,eval);}
typedef ErrorStream&(*ErrManip)(ErrorStream&);
//零参数机械手应用装置
friend ErrorStream&操作员
表示您的
ErrorStream
是一种
ostream
,这意味着它自身的一部分是一种
ostream

   ostream& my_os;
这表示您的
ErrorStream
还包含对ostream对象的引用。我相当确定这两个对象中的一个是错误的。
ErrorStream
是流还是包含对流的引用?因为您似乎默认为
cerr
,我相信您想要该成员

ErrorStream(ostream& user_os = cerr) :  errcount(0),
                ios(&buffr),buffr((ErrorStream*)this),
            my_os(user_os),prog(NULL),errstatus(0) { } //HERE
此构造函数导致错误,因为您初始化了成员
my_os
,但从未告诉它如何构造父
ostream
对象。编译器会尝试默认构造它,但
class ErrorStream : public ostream, virtual public ios
{
   ostream& my_os;
ErrorStream(ostream& user_os = cerr) :  errcount(0),
                ios(&buffr),buffr((ErrorStream*)this),
            my_os(user_os),prog(NULL),errstatus(0) { } //HERE
operator std::ostream&() {return my_os;}