title: How to register a dynamic member in C++
body: <p>Magic methods in python are really magical. For example:</p>
  <pre class="lang-py prettyprint-override"><code>class DynMember:
  
      def __getattr__(self, name: str):
          def fn(self, **kwargs):
              print(kwargs)
  
          setattr(self.__class__, name, fn)
  
          return lambda **x: fn(self, **x)
  
  if __name__ == &quot;__main__&quot;:
      d = DynMember()
      d.someFn(title=&quot;Greeting&quot;, description=&quot;Hello world!&quot;) # outputs {'title': 'Greeting', 'description': 'Hello world!'}
      d.someFn(k1=&quot;value 1&quot;, k2=&quot;value 2&quot;) # outputs {'k1': 'value 1', 'k2': 'value 2'}
  </code></pre>
  <p>There was no <code>someFn</code> in <code>DynMember</code> class. The method is set on the class using <code>__getattr__</code> magic method and <code>setattr</code> builtin method. These methods are really powerful and make classes do wonders in python. (have written a html generator only in 40 lines of code). How to achieve something similar in C++?</p>