C++ ifstream has incomplete type
问题 I'm modifying an project where I want to write an output to a file. In my .hpp file I declared a file stream like so: // fname.hpp file #include <fstream> std::ifstream m_ifs = ("path_to_file"); then on my .cpp file I am have // fname.cpp if (!m_ifs.is_open()) { std::cerr << "Not writing to file" << std::endl; return; } m_ifs << "Write something" But when I compile I get the following error: error: field ‘m_ifs’ has incomplete type ‘std::ifstream {aka std::basic_ifstream<char>}’ /usr/include