🔒 Locked
Initializing Static Const in Class Problem
Advertisement
Original Post
#include <iostream>class foo {public: static const int i = 420; // initialize static const in-class static const int j;};// const foo::i; // not necessaryconst foo::j = 69; // initialize static const out-classint main() { std::cout << foo::i << std::endl; std::cout << foo::j << std::endl; return 0;}
Quote:
Original post by gumpy macdrunken class foo{ static const std::string bar;};const std::string foo::bar( "foobar!" );
edit: boy am i slow and distracted today...
I see, thanks. And that initialization can sit in the header file even if the header file is included in multiple modules? Does this mean it can get initialized more than once when each module is loaded?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement