Saturday, September 23, 2017

Digest for comp.lang.c++@googlegroups.com - 2 updates in 1 topic

Juha Nieminen <nospam@thanks.invalid>: Sep 23 07:15AM

> head=new node (a[i],head);
> }
> };
 
Not an answer to your actual question, but you really shouldn't
be creating your own dynamically allocated data structures if
you are not going to follow the meticulous requirements to make
it safe. Your linked_list class above is plagued with multitudes
of problems (starting with the fact that you allocate nodes
with 'new' but you don't 'delete' them anywhere. But that's just
the *start* of the problems.)
 
In general, unless there's a good reason not to, if you want to
use a linked list, use std::list or std::forward_list.
 
(The only reasons to create your own implementation is as an
exercise in C++, in which case you really, really should follow
the rule of threes (or fours as is the case with C++11), or if
you require a special list that's somehow different from the
standard one (in which case you *also* should follow the rule of
threes as well.))
ruben safir <ruben@mrbrklyn.com>: Sep 23 06:44PM -0400

On 09/22/2017 12:33 AM, Barry Schwarz wrote:
> for (i = 0; i < vector.size; i++)
> {do something with v[i]}
 
for(auto x:v )
{ do something with x}
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: