The majority of forums are now only available as archives, which means posting/editing is disabled.
The Anything and Everything forum is still open.
The Anything and Everything forum is still open.
Dynamic arrays of structures, operator usage
|
|||
|
Rank: ? (2)
Member #: 27416 |
Just a quick question. I'm trying to creat and populate a dynamic array of structs, but the compiler is not reacting as I would expect. I'm using Dev-C++.
Code:
after this, I would expect the operator to be used to populate each pointer to be ->, but when I try this... Code:
the compiler returns 16 D:\...\chips.cpp base operand of `->' has non-pointer type `Chips' If I switch over to the . operator, the compiler goes without a hitch, but this leads me to believe that the program isn't working off of pointers, thus making me question whether the memory is being properly allocated with 'new'. Can anyone clue me in as to what's going on here? Also, as an aside, is there code to initialize a structure within a dynamic array, or do I have to populate each pointer location individually? Thanks, DT » Post edited 2006-05-05, 06:54pm by Devilturnip.
|
||
|
|||
|
|||
|
Rank: ? (768)
Member #: 11085 |
When you create a dynamic array of structures or classes, using the offest operator ([X]) makes it so that you should use . and not ->
- relpats_eht
|
||
|
|||
|
|||
|
Rank: ? (2)
Member #: 27416 |
So everything is operating right with the . operator? Muchas gracias.
|
||
|
Please login or register to post a reply.
