For Programmers: Free Programming Magazines  


Home > Archive > VC STL > August 2005 > STL' Set as variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author STL' Set as variable
Davy

2005-08-17, 9:29 am

Hi all,

I want to use STL's Set as variable.
The function type :

set<int> get_set_child(set<int> set_parent) {
do something...
return set_child
}

Is the set_parent variable input as reference(pointer)? If the
set_parent input as value, can I use (set<int> * set_parent) as input?

Best regards,
Robert

Ulrich Eckhardt

2005-08-17, 5:07 pm

Davy wrote:
> I want to use STL's Set as variable.
> The function type :
>
> set<int> get_set_child(set<int> set_parent) {
> do something...
> return set_child
> }
>
> Is the set_parent variable input as reference(pointer)? If the
> set_parent input as value, can I use (set<int> * set_parent) as input?


I'm not exactly sure what you mean, but all containers are fully copyable
and assignable, just like an int or a float.

Passing or returning large objects by value has some overhead due to copying
though, so is not always the most efficient choice. However, avoiding that
is an optimisation that you can do once you know the language proper and
have profiled the code so that you know that this is the bottleneck in your
application.

Uli

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com