code_junkie

Defining class string constants in C++

Nov 13th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. //Example1
  2. class Test {
  3.  
  4. private:
  5. static const char* const str;
  6.  
  7. };
  8.  
  9. const char* const Test::str = "mystr";
  10.  
  11. //Example2
  12. class Test {
  13.  
  14. private:
  15. static const std::string str;
  16.  
  17. };
  18.  
  19. const std::string Test::str ="mystr";
Add Comment
Please, Sign In to add comment