title: How to define a macro that retains its scope after it's been called
body: <p>I'm trying to make a macro to make it easier to define properties.</p>
  
  <p>Simplified example but at the moment I have this to provide a property with a public get and private set:</p>
  
  <pre><code>#define propertyRO(xxType, xxName)\
      property xxType xxName\
      {\
          xxType get() {return m___##xxName;}\
          void set(xxType value) {m___##xxName = value;}\
      }\
      private:\
          xxType m___##xxName;\
  </code></pre>
  
  <p>and then to use it you would do this:</p>
  
  <pre><code>public ref class Wawawa
  {
  public:
      int bob;
      propertyRO(String^, MyName);
  };
  </code></pre>
  
  <p>This would potentially work great, but it's flawed because the member is specified in private scope, which means anything that occurs after the macro also gets private scope. e.g:</p>
  
  <pre><code>public ref class Wawawa
  {
  public:
      int bob;
      propertyRO(String^, MyName);
      int fred; //ERROR HERE &lt;- this would be private not public
  };
  </code></pre>
  
  <p>So if you ignore what this macro actually does, my real question is: is there any way to use the <code>private:</code> keyword in a macro, without it affecting the rest of the class?</p>