C++: variable 'std::ifstream ifs' has initializer but incomplete type

后端 未结 1 396
深忆病人
深忆病人 2020-12-23 12:53

Sorry if this is pretty noobish, but I\'m pretty new to C++. I\'m trying to open a file and read it using ifstream:

vector load_f(         


        
1条回答
  •  有刺的猬
    2020-12-23 13:18

    This seems to be answered - #include .

    The message means :-

    incomplete type - the class has not been defined with a full class. The compiler has seen statements such as class ifstream; which allow it to understand that a class exists, but does not know how much memory the class takes up.

    The forward declaration allows the compiler to make more sense of :-

    void BindInput( ifstream & inputChannel ); 
    

    It understands the class exists, and can send pointers and references through code without being able to create the class, see any data within the class, or call any methods of the class.

    The has initializer seems a bit extraneous, but is saying that the incomplete object is being created.

    0 讨论(0)
提交回复
热议问题