PDA

View Full Version : Forward declaration with std namespace



Raistlin
5th March 2007, 18:45
I am writing a software development kit and would like to use as much forward declarations as possible. One of the used classes is std::fstream, but I do not want to include <fstream> in the header files, since I do not want external includes.

However, how to use a forward declaration as the following without using the std notation ? I could use a void* as work-around, but that does not sound like a clean solution.



class SmallClass;
//class std::fstream; is not accepted by the compiler, for obvious reasons

class Bigclass {
public:
...

private:
SmallClass* smallObject_;
}

danadam
5th March 2007, 21:11
[...] One of the used classes is std::fstream, but I do not want to include <fstream> in the header files, since I do not want external includes.

However, how to use a forward declaration as the following without using the std notation ?

You can use iosfwd header file:
#include <iosfwd>. See description (http://www.dinkumware.com/manuals/?manual=compleat&page=iosfwd.html).

Raistlin
5th March 2007, 21:45
Exacly what I need, thanks :)