I have :
class Foo {
public:
void log() { }
void a() {
log();
}
void b() {
log();
}
};
Is there a way that I can have each method of Foo
, call log()
, but without me having to explicitly type log() as the first line of each function ?
I want to do this, so that I can add behaviour to each function without having to go through each function and make sure the call is made, and also so that when I add new functions, the code is automatically added...
Is this even possible ? I can't imagine how to do this with macro's, so not sure where to begin... The only way I have thought of so far, is to add a "pre-build step", so that before compiling I scan the file and edit the source code, but that doesn't seem very intelligent....
EDIT: Just to clarify - I don't want log() to call itself obviously. It doesn't need to be part of the class.
EDIT: I would prefer using methods that would work cross platform, and using only the stl.