Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. class Person
  2. {
  3. protected:
  4. bool initialized = false;
  5. std::string name;
  6.  
  7. void Initialize()
  8. {
  9. name = "My name!"; // do heavy reading from database
  10. initialized = true;
  11. }
  12.  
  13. public:
  14. std::string GetName()
  15. {
  16. if (!initialized) {
  17. Initialize();
  18. }
  19.  
  20. return name;
  21. }
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement