Untitled
unknown
plain_text
a year ago
670 B
16
Indexable
struct Cfg {
int x;
int y;
};
class TestBase {
Cfg cfg;
};
class Test : public TestBase {
Test():
work{cfg} // I need parsed cfg here
{
}
Work work; // piece of work nvm
};
int parse_int_from_env(int default) {
// if not in env, return default
...
}
class CfgParser {
CfgParser(Test* test, const Cfg& defaults) {
test->cfg.x = parse_int_from_env(defaults.x);
test->cfg.y = parse_int_from_env(defaults.y);
}
};
class ConcreteTest : public CfgParser, Test {
ConcreteTest():
CfgParser(this, {.x = 6, .y = 8}),
Test()
{}
};
Editor is loading...
Leave a Comment