D
Donald Gillies
So I have a virtual base class. I want each child class to have its
own unique log. There may be hundreds of child classes but all
classes of a particular type should share one log.
After scratching my head a few moments I decided what I really wanted
was this :
class baseClass {
virtual static ofstream _logFile;
void InitLogFile(char *baseName);
void LogSomething(int a, int b, ...);
};
class Child : public baseClass {
static ofstream _logFile;
};
There really isn't a way to do this well in C++, is there? As someone
who knows a little about C++ and assembly language, it would not be
hard to make the virtual storage a pointer in vtable that points to
the static storage - different for every subclass.
I cannot think of a way of doing it without burning a lot of needless
storage. I think this supports my belief that if Bjarne couldn't
think of it in 1986, your application of C++ was NOT PROVIDED FOR in
the design of the C++ programming language ... EOT.
- Don Gillies
San Diego, CA
own unique log. There may be hundreds of child classes but all
classes of a particular type should share one log.
After scratching my head a few moments I decided what I really wanted
was this :
class baseClass {
virtual static ofstream _logFile;
void InitLogFile(char *baseName);
void LogSomething(int a, int b, ...);
};
class Child : public baseClass {
static ofstream _logFile;
};
There really isn't a way to do this well in C++, is there? As someone
who knows a little about C++ and assembly language, it would not be
hard to make the virtual storage a pointer in vtable that points to
the static storage - different for every subclass.
I cannot think of a way of doing it without burning a lot of needless
storage. I think this supports my belief that if Bjarne couldn't
think of it in 1986, your application of C++ was NOT PROVIDED FOR in
the design of the C++ programming language ... EOT.
- Don Gillies
San Diego, CA