Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ c++;错误C2512_C++_Constructor - Fatal编程技术网

C++ c++;错误C2512

C++ c++;错误C2512,c++,constructor,C++,Constructor,我得到了一个错误: error C2512:'std::basic_ostream<_Elem,_Traits>' : no appropriate default constructor available 错误C2512:'std::basic_ostream':没有合适的默认值 可用的构造函数 使用以下代码: class Sentence { public: Sentence(void){} ~Sentence(void); static void

我得到了一个错误:

error C2512:'std::basic_ostream<_Elem,_Traits>' : no appropriate default
constructor available
错误C2512:'std::basic_ostream':没有合适的默认值
可用的构造函数
使用以下代码:

class Sentence
{
public:
    Sentence(void){}
    ~Sentence(void);
    static void CreateHeader(std:string& s);
    class Word {
        public:
            std:ostream s;

            Sentence::Word(){ s<<""; }

            Word(char*);
            ~Word();
    };
};
类语句
{
公众:
判决(无效){}
~判决(无效);
静态void-CreateHeader(标准:字符串&s);
类词{
公众:
标准:ostream s;

语句::Word(){sstd:ostream没有默认构造函数-请参阅


你想做什么?你是在寻找std::cout、std::ofstream还是std::stringstream?

以下是msdn的解释

简而言之,您需要添加一个默认构造函数:

Sentence(){}

你能把它翻译成英语吗?
std:streams
应该是什么意思?你打算从std::ostream派生吗?嗨,谢谢,但这是我程序的第四行,请参见下文,而不是说谢谢加一个我的post:DNo,因为我已经这么做了,请在我的第一句话(void){}中重新阅读我的代码在第4行中,我想在我的类中有一个“ostream”,并用一个“操作符”将它添加到一些字符串中