No Problem, Rajesh. Oh BTW, my name is Joseph. lol

--- rajesh bisht <[EMAIL PROTECTED]> wrote:

> Dear Josef. Thanks. 
>   URL is very usefull.
>    
>   Thanks .
>   
> 
> "Joseph A. Marrero" <[EMAIL PROTECTED]> wrote:
>   
> 
> 
> --- John Matthews wrote:
> 
> > Hi- first of all, I'm saving up for one of the good C++
> > books. Until
> > then, I hope you won't mind me asking some beginners'
> C++
> > questions.
> > 
> > In some C code I've written previously, I have a home
> > made generic
> > list type which is told how big list items are. So
> > list_add()
> > allocates enough memory for a new item and returns a
> > pointer to it, so
> > that the caller can set the item's value. Eg. (in C,
> > simple code to
> > attempt to demonstrate my point)
> > 
> > typedef struct
> > {
> > int value;
> > } Item;
> > 
> > int main(void)
> > {
> > List items;
> > Item *item_p;
> > /* Initialise the list. */
> > list_init(&items, sizeof *item_p);
> > /* Add (uninitialised) item to end of list. */
> > item_p = list_add(&items);
> > /* Initialise the new item in the list. */
> > item_p->value = 3;
> > 
> > Now if I am using STL, this is currently my attempt at
> > the above:
> > 
> > class Item
> > {
> > public:
> > Item(int v) { value = v; }
> > int value;
> > };
> > 
> > int main()
> > {
> > list items;
> > Item item(3);
> > items.push_back(item);
> > 
> > What bothers me slightly is that in the C version,
> there
> > is only one
> > Item - it is created by list_add(), and referenced by a
> > pointer.
> > 
> > However, in my C++ version, there are 2 items (as I
> > understand it) -
> > the local variable item, which is initialised and
> passed
> > to
> > push_back() to create a copy of it in the list.
> 
> 
> Hi John. You may find the following URLs helpful:
> 
>
http://www.robthebloke.org/cppdir/StandardTemplateLibrary.htm
> http://www.robthebloke.org/
> 
> 
> 
> > 
> > If this is the right and proper way to do it, then
> fine.
> > But I suspect
> > I'm probably missing something.
> > 
> > Any help appreciated. I've done some Googling for STL
> but
> > not been too
> > impressed by what I've found so far - if anyone knows
> of
> > a good online
> > STL resource then that would also be gratefully
> received.
> > 
> > BTW I'm working in Linux with g++ on the command line.
> > 
> > Cheers
> > John
> > 
> > 
> 
> 
> _________________
> Joseph A. Marrero
> http://www.l33tprogrammer.com/
> 
> 
> 
>
____________________________________________________________________________________
> Do you Yahoo!?
> Everyone is raving about the all-new Yahoo! Mail beta.
> http://new.mail.yahoo.com
> 
> 
> To unsubscribe, send a blank message to . 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
>  
> ---------------------------------
> Bored stiff? Loosen up...
> Download and play hundreds of games for free on Yahoo!
Games.


_________________
Joseph A. Marrero
http://www.l33tprogrammer.com/


 
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited

Reply via email to