FA> Is it possible to make a class aware of another instance of itself ?
FA> If it is, how would that be done ?
FA> eg:
FA> class foo
FA> {
FA> foo()
FA> {
FA> if(we_re_not_alone) ...
FA> else ...
FA> }
FA> };
Sure:
//foo.h
class foo
{
public:
foo();
~foo();
private:
static unsigned int howMany;
};
//foo.cpp
unsigned int foo::howMany = 0;
foo::foo()
{
++howMany;
if (howMany>1)
...
else
...
}
foo::~foo()
{
--howMany;
}
Thomas
---
þ MM 1.0 #0113 þ A tree never hits an automobile except in self-defense.
---------------
* Origin: McMeier & Son BBS (2:301/138)
|