jose luis fernandez diaz wrote:
> This code is extracted from "The C++ Programming Language"
> Stroustrup's book. It is strange to me that Strousptrup writes useless
> code, but it seems that that is the case.
It's not "useless code". When debugging temporary variables help quite
significantly. Once you figured that the constructors and copying are
all working correctly, you can get rid of "unnecessary" objects, but
that usually takes time without any added benefit to the code itself.
I hope that you eventually become a published author in some area and
never make "mistakes" like the one you decided to point out today. Once
you figured out how not to top-post, that is.
V
>
> Regards,
> Jose Luis.
>
> (jose luis fernandez diaz) wrote in message news:<. com>...
>
>>Hi,
>>
>>In the next class:
>>
>>template<class T> class Set_controller
>>{
>> Set<T>* rep;
>> Lock lock;
>>public:
>> void insert(T* p) { Lock_ptr x(lock); rep->insert(p); }
>> void remove(T* p) { Lock_ptr x(lock); rep->remove(p); }
>>
>> int is_member(T *p) { return rep->is_member(p); }
>>
>> T get_first() { T* p=rep->first(); return p ? *p : T(); }
>> T get_next() { T* p=rep->next(); return p ? *p : T(); }
>>
>> T first() { Lock_ptr x(lock); T tmp = *rep->first(); return tmp; }
>> T next() { Lock_ptr x(lock); T tmp = *rep->next(); return tmp; }
>>
>>
>> // . . .
>>
>>};
>>
>>
>>
>>What is the difference between:
>>
>> T first() { Lock_ptr x(lock); T tmp = *rep->first(); return tmp; }
>>
>>and
>>
>> T first() { Lock_ptr x(lock); return *rep->first(); }
>>
>>Thanks,
>>Jose Luis.
--
Please remove capital As from my address when replying by mail