Advertisement
bkuhns

Untitled

Mar 1st, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. class Foobar {
  2.  
  3.  
  4. public:
  5.     Foobar() : index(this) {};
  6.  
  7.     void SetIndex(const int& value) { m_index = value; }
  8.     const int& GetIndex() { return m_index; }
  9.  
  10.     Property<Foobar, int, &Foobar::GetIndex, &Foobar::SetIndex> index;
  11.  
  12.  
  13. private:
  14.     int m_index;
  15.  
  16.  
  17. };
  18.  
  19.  
  20. void someTest(int& num) {
  21.     num++;
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27.     auto myFoo = std::unique_ptr<Foobar>(new Foobar());
  28.     myFoo->index = 5;
  29.  
  30.     std::cout << myFoo->index << std::endl;
  31.  
  32.     someTest((int)myFoo->index);
  33.  
  34.     std::cout << myFoo->index << std::endl;
  35.  
  36.     return 0;
  37. }
  38.  
  39. /* Output:
  40.  * 5
  41.  * 6
  42.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement