Re: Correction


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by John Kugelman on March 24, 2001 at 07:20:06:

In Reply to: Re: Correction posted by Anthony Zucaro on March 23, 2001 at 12:35:52:

: I have tried using typedef's and by dereferencing, and neither work.

With the typedef example I was trying to demonstrate why you have to dereference first.

If you have a declaration like

: ArrayT book_array (size);

(if I lose part of that due to HTML, it should read "ArrayT {Book} book_array..." where { and } are angle brackets)

then you can use the brackets like

: book_array [index]

But if your declaration is

: ArrayT *book_array = new ArrayT (size)

(again, should read "ArrayT {Book} *book_array", but with angle brackets) then you would access it like

: (*book_array) [index]

You see? You deference the pointer and then use the brackets. Note that you have to parenthesize the deference because of operator precedence.


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]