So I have code like:
// puma.cpp
#include "FILE_WITH_MACROS.hpp"
ANIMAL_MACROS_NAME_HERE class puma : public animal {
public:
puma(int age) : animal(age) {}
virtual std::string get_name() {
return "puma";
}
};
//end of puma.cpp and here we want to add some more code via ANIMAL_MACROS_NAME_HERE macros.
Can my macros that I use in the middle of my C++ file add some code to the end of my file?
No, but you can always add another macro in the end of the file.
In some cases it can be possible to do something like this:
Then you would define the classes with the outer macro like this:
This can of course be extended various ways depending on needs. However, it’s restricted in certain cases e.g. where the classes you want to specify vary and do not follow a simple convention which can be put in a macro.