Sunday, August 20, 2006

Namespace a Real Boon

Sometimes it hapens that we have to use the classes provided by third party people and when two classes have the same name it leads to class redefenition compile time error and we can't change the header files because they are the root of the lib implementaion or others.

So how do you resolve this :-
namespace FirstClass
{
#include "FirstClass.h"
}

namespace SecondClass
{
#include "SecondClass.h"
}
FirstClass::CMyclass and the SecondClass::CMyClass are refering to two different classes therby resolving the compile time error.
But maybe you have to look out for the linktime error :).

NOTE:- Any class you make it should be in the namespace .

No comments: