This question has already been answered:
looked at the source code iostream and there is such a construction
namespace std { extern istream cin; extern ostream cout; extern ostream cerr; extern ostream clog; } I tried to do the same:
class AA { public : ... }; class BB { public : ... }; namespace OO { extern AA test1; extern BB test2; } but each time it compiles, it throws out something like that — an undefined reference to OO :: test1. If you do without extern, it will knock out a multiple definition. Tell me how to solve this problem? thank.
namespace OO {AA test1; BB test2;}namespace OO {AA test1; BB test2;}, not forgetting to make a header with class definitions. Or another option: Replaceexterntoinline. - HolyBlackCat 5:14