Re: create an object with variable CLASS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Axel,
I said my means badly,Suppose I have following code:
module_management::load_module(char *class_name){
}/////////////////////
I wanna create an object for each class that it is argument of my
function.
same: 
class_name *my_obj = new class_name;
I can't implement it.
Yours,
Mohsen 
On Mon, 2009-10-26 at 10:55 +0100, Axel Freyn wrote:
> Hi,
> On Tue, Oct 27, 2009 at 12:31:05AM +0330, Mohsen Pahlevanzadeh wrote:
> > Oh, I forgot that i say i need to variable name of objects.same classes.
> > Therefor i need to variable name of objects & variable name of classes.
> > On Mon, 2009-10-26 at 23:42 +0330, Mohsen Pahlevanzadeh wrote:
> > > Dear all,
> > > We know that we can create an object with following code:
> > > /////////////////////////////////////////////////
> > > class_name *object_name = new() class_name;
> > > ///////////////////////////////////////////////
> > > So, i have a class pool,I wanna create Object with a variable name that
> > > variable is my class.Same:
> > > var *obj = new() var;
> > > var is a variable that contains a my class's name.
> > > How can i implement it?
> Well, I'm not sure I understand correctly, but I think the solution is
> derivation:
> class Base{};
> class A:public Base{};
> class B:public Base{};
> ...
> 
> 
> Then you can do:
> Base *var;
> var = new A;
> delete var;
> var = new B;
> delete B;
> 
> All functions, which you want to call by accessing "var" (e.g.
> var->Function()) have to be defined as virtual function in class Base.
> 
> Does that solve your problem?
> 
> Axel



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux