| Declare in namespace |
[20 Jan 2007|03:16pm] |
While reading from Stroustrup C++ 3rd Edition, I don't understand how correctly use namespaces when using header files.
I come from C, and I always try not to include files inside header files. Only C files will include headers.
Imagine a header mentions a foreign type. We could declare (and not define) it:
class Myclass;
void myfunc(Myclass tmp);
I found I cannot do the same as in the example, if the class is in a namespace. Imagine a similar header file:
/* How to declare std::wstring without including <string>? */
void myfunc(std::wstring tmp);
How would you declare "std:wstring", and still allowing a C++ source file to do:
#include <string>
#include "myheader.h"
...
I'm not sure if I explained my problem correctly... let me know through comments. Thanks!
|
|