[LC++]temporals objects

Roberto Diaz roberto at vivaldi.dhis.org
Mon Dec 17 14:22:47 UTC 2001


> But why would you want this?  Why not just do:
> 
> OtherClass b;
> a.push_back(b);

Because .push_back() is intented to be a method for a general container with no
limits to the size of the objects it can contain.. and at times I want to pass
temporals.. other times I can pass a reference.

So sometimes I want to be able to make this:

a.push_back (MyClass (..)); // here we have a temporal we have to pass by copy

Others just 
MyClass b;
a.pushback (&b); // here we can pass by reference.

Anyway.. I 've just overloaded .push_back().. the problem is when you want to
have a method like this with much more paramenters.. then it is a pain to
write:

void myMethod (MyClass a, MyOtherClass b);
void myMethod (MyClass &a, MyOtherClass b);
void myMethod (MyClass a, MyOtherClass &b);
void myMethod (MyClass &a, MyOtherClass &b);

but anyway.. this is the way to go.. I guess.. :)

Thank you!

-- 
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