Reputation: 31
Is there any way to define conastant foo in c++ header "foo.hpp"
const int foo;
and initialize it with value returned by function bar defined in "bar.hpp"
int bar();
? (Either in foo.hpp or in foo.cpp.)
Upvotes: 0
Views: 107
Reputation: 31685
Write
extern const int foo;
in foo.hpp and
const int foo = bar();
in foo.cpp.
Upvotes: 1