Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person
- {
- protected:
- bool initialized = false;
- std::string name;
- void Initialize()
- {
- name = "My name!"; // do heavy reading from database
- initialized = true;
- }
- public:
- std::string GetName()
- {
- if (!initialized) {
- Initialize();
- }
- return name;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement