Hay,
is it possible add propertys to class in runtime?
for example:
in design time I have empty class:
class MyClass
{
};
can I add to this class __propertis and methods in runtime ?
Thank very much .
Bye.
1 reply to this topic
#1
Posted 19 August 2010 - 03:06 AM
|
|
|
#2
Posted 19 August 2010 - 03:43 AM
Well not like the normal static way but you could do it by a form of interface with functions and storing the properties in a container. You could fix this with dynamic memory allocation but this method will be more static and let you work without pointers and the problems that come with it.
I always follow "Keep-It-Simple-Stupid" ^^
class MyClass {
public:
struct Property {
enum {
// All different types identifier here
} type;
union {
// All memory storage for the different types.
} data;
};
// You can also do several overloaded versions for each type you accept.
void SetProperty(std::string name, Property prop);
Property GetProperty(std::string name);
private:
std::map<std::string, Property> myProperties;
};
I always follow "Keep-It-Simple-Stupid" ^^
My Code Blog - My Github - Ascension Project - Madness Script Project - Simple-Garbage-Collector Project
There is bound to be something useful somewhere.
There is bound to be something useful somewhere.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









