[LC++]temporals objects

Roberto Diaz roberto at vivaldi.dhis.org
Sat Dec 15 07:00:05 UTC 2001


Hi!

I have some problems with temporal objects.. I want to call a method 
this way:

MyClass a;
a.push_back (OtherClass("this"));

Where OtherClass implements a constructor like 
OtherClass::OtherClass ( const char *);

if I define push_back() like this:

void push_back (OtherClass *);

Of course this cant work because if I call it later this way:

a.push_back(&OtherClass("this")); 

the compiler complains because I am taking the address from a temporal object..

I need the method push_back () to be able to take an address so I can do this
too:

OtherClass b;
a.push_back(&b);

and:

a.push_back (take_temporal_object_somehow);

The first solution I find is to overload push_back() in order to support both..
but this solution looks overkilling (I have much more parameters with this
problem).

To use references doesnt help since to take a reference from a temporal is the
same bad as to take its address..

Any solution but overloading?

Thank you!

Roberto 



-- 
Saludos

Roberto Díaz <roberto at vivaldi.dhis.org>

PLEASE HELP SAVE faqs.org!
http://www.faqs.org/save_faqs-org.html



More information about the tuxCPProgramming mailing list