Forward declarations are a great way to eliminate needless compile-time dependencies. But here's an example of a forward-declaration snare . How would you avoid it?
Forward declarations are very useful tools. In this case, they don't work as the programmer expected. Why are the marked lines errors?
// file f.h // class ostream; // error class string; // error string f( const ostream& );
Without including any other files, write the correct forward declarations for ostream and string above.