Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. template<class T>
  2. struct IsSetProperty
  3. {
  4. IsSetProperty(): property(0), isSetProperty(false)
  5. {
  6. }
  7. T property;
  8. bool isSetProperty;
  9. };
  10.  
  11.  
  12. class Foo
  13. {
  14. public:
  15. Foo(): property1(0), isSetProperty1(false)
  16. {
  17. }
  18. //getter + setters depending on the case #1 or #2
  19. private:
  20. // first case using another bool to ensure that property is set.
  21. int property1;
  22. bool isSetProperty1;
  23. // second case using struct IsSetProperty
  24. IsSetProperty<int> property2;
  25. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement