I've come to like using forward declarations in header files to reduce compile times, for example:
// dostuff.h
class foo;
void DoPtrStuff(foo*);
void DoRefStuff(foo&);
as opposed to:
// dostuff.h
#include "foo.h"
void dostuff(foo*);
void DoPtrStuff(foo*);
void DoRefStuff(foo&);
Since in the second example every file that includes "dostuff.h" also gets all the baggage associated with "foo.h".
My question is, is there a way to get this to work when the class you are using the forward declaration for is in a namespace? I'll give a specific example of something I'm trying to do but can't get to work:
class std::string;
void foo( std::string& );
or:
namespace std{
class string;
}
void foo( std::string& );
Neither of these compile ( in Visual Studio .NET 2003 ), and although I've tried several different variations I can't find one that will compile.
There are 10 types of people in the world: Those who know binary and those who don''t.