Skip to content

Instantly share code, notes, and snippets.

@carmel4a
Last active September 7, 2018 08:55
Show Gist options
  • Save carmel4a/6558ffef4c2e845d1b94251c12575967 to your computer and use it in GitHub Desktop.
Save carmel4a/6558ffef4c2e845d1b94251c12575967 to your computer and use it in GitHub Desktop.
#include <iostream>
namespace ModuleA
{
struct Config
{
static unsigned char ( * get_next_byte_function)(void);
};
unsigned char (*Config::get_next_byte_function)(void)
= []()-> unsigned char{ return '\0';};
}
//// Other src file ////
namespace ModuleB
{
struct Config
{
static unsigned char (* get_next_byte_function)(void);
};
unsigned char (*Config::get_next_byte_function)(void)
= []()-> unsigned char{ return '\0';};
}
//// Other src file ////
namespace ModuleUtilities
{
unsigned char get_next_byte()
{
std::cout << "3";
return '3';
};
}
/// Main/Logic file ///
int main()
{
ModuleA::Config::get_next_byte_function = &ModuleUtilities::get_next_byte;
ModuleB::Config::get_next_byte_function = &ModuleUtilities::get_next_byte;
ModuleB::Config::get_next_byte_function();
ModuleB::Config::get_next_byte_function();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment