This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Can I use the dynamic memory allocation on the class object? Thanks a lot.


Hi all:
I would like to use the dynamic memory allocation on the Class object
creation, but how is its associated class constructor called?

foe example:

class my_class
{ 
   public:
    int a
    my_class() { a=100;}
    ~my_class(){};
}


my_class *pclass = malloc(sizeof(my_class));

// by now has the my_class constructor been called?, or should I call it by myself?
// I have tried the following: (I guess only the global class object constructor will be called when system started)

pclass->my_class();	// error

// or must I set it by
pclass->a=100;

thanks a lot.


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]