How to add new property to an object at runtime in C++?
c++, properties
Solution
You can't just add "properties" to objects -- the concept of an object is done completely at compile time. At run time, the CPU doesn't know that a given block of memory is called an "object" or whatever you decided to call an instance of a class.
(This in and of itself is kind of interesting because C++ does not have properties)
If you just want a data field that you refer to by name, any of the standard associative containers should do what you need.
Problem
In C# we can use something like this: ``` MyClass c = new MyClass(); c.Properties.Add("another property", "another value"); ``` I need to do this in C++. I'm using VS 2012. Any ideas? Edited: Know, that I can use map, or any list to save property to object, like: ``` void ObjectProperty::addItem(string key, XProperty p) { _object[key] = p; } ```