Certain situations in my code, i end up invoking the function only if that function is defined, or else i should not. How can i achieve this ?
like:
if (func
When you declare 'sum' you could declare it like:
#define SUM_EXISTS
int sum(std::vector& addMeUp) {
...
}
Then when you come to use it you could go:
#ifdef SUM_EXISTS
int result = sum(x);
...
#endif
I'm guessing you're coming from a scripting language where things are all done at runtime. The main thing to remember with C++ is the two phases:
So all the #define and things like that happen at compile time.
....
If you really wanted to do it all at runtime .. you might be interested in using some of the component architecture products out there.
Or maybe a plugin kind of architecture is what you're after.