C
Christopher
Is this a bad idea? I think it is. However, I am having a bit of trouble explaining why.
I generally frown on globals in the first place, but this seems even worse. Sharing a global from one library with other libraries?
Every 3rd Party lib I've used doesn't do this.
-----
In Lib 1, In A.H:
class A
{
// Various methods and data
};
extern A * pA;
-----
In Lib 1, In A.cpp:
A * pA = NULL;
-----
In Lib 2, in something.cpp:
#include "A.h"
A a;
void SomeMethod()
{
pA = &a;
}
-----
In Lib 3, in someother.cpp
void SomeOtherMethod()
{
pA->DoStuff();
}
I generally frown on globals in the first place, but this seems even worse. Sharing a global from one library with other libraries?
Every 3rd Party lib I've used doesn't do this.
-----
In Lib 1, In A.H:
class A
{
// Various methods and data
};
extern A * pA;
-----
In Lib 1, In A.cpp:
A * pA = NULL;
-----
In Lib 2, in something.cpp:
#include "A.h"
A a;
void SomeMethod()
{
pA = &a;
}
-----
In Lib 3, in someother.cpp
void SomeOtherMethod()
{
pA->DoStuff();
}