title: C++ imitating properties from C#
body: <p>I really miss get/set in C++, so I'm trying to do something similar. This is what I have now:</p>
  <pre><code>#pragma once
  #define Property(T) class : public property&lt;T&gt;
  #define Get(T) T* get() override
  #define Set(T) T* set(T* _value) override
  #define MutableProperty(T) using property&lt;T&gt;::operator=
  #include &lt;ostream&gt;
  
  
  template&lt;typename T&gt;
  class property
  {
  protected:
      T* value;
      virtual T* get() = 0;
      virtual T* set(T* _value) = 0;
  public:
      property()
      {
          value = NULL;
      }
      ~property()
      {
          delete value;
      }
      T* operator=(T* _value)
      {
          return set(_value);
      }
      T* operator=(T _value)
      {
          return set(new T(_value));
      }
      operator T*()
      {
          return get();
      }
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, property&amp; prop)
      {
          return out &lt;&lt; *prop.get();
      }
  };
  </code></pre>
  <p>and this works like this:</p>
  <pre><code>#include &quot;Property.h&quot;
  Property(string)
  {
      Get(string)
      {
          return value;
      }
      Set(string)
      {
          return value = _value;
      }
  public:
  
      MutableProperty(string);
  } strprop;
  
  int main()
  {
      strprop = &quot;teststring&quot;;
      cout &lt;&lt; strprop;
      getchar();
      return 0;
  }
  </code></pre>
  <p>which I already like how it looks, but is there any trick of getting rid of those Get(type) Set(type)?<br />
  Also, is this actually good approach or this is poor code?</p>