Re: Heap vs. Stack

Posted 19 April 2010 - 12:46 PM

-> is not the same . Let's take the construction a.b. Even though we aren't involving any actual types here, syntactically there are some clear requirements. a has to be a struct, class, or union. a->b is the same as (*a).b That means a is pointer to a struct, class, or union.

It should be clear that you need to figure out what the type of a is, and then use the appropriate syntax to access a member.

Re: Heap vs. Stack

Posted 19 April 2010 - 12:55 PM

If you know how many CATs you want at compile time, use the stack, otherwise use the heap.

Also, your function prototypes don't match the implementation. You don't need to0 pass a pointer to a CAT object, since you aren't modifying any of its data and I'm pretty sure you'd be ok with the performance hit/shallow copying.

Re: Heap vs. Stack

Posted 19 April 2010 - 12:55 PM

Where did you pull calloc out of what KYA just said? You can certainly use it (I do all the time...I like my variables initialized into a known state always), but it suggests you are perhaps getting conflicting information elsewhere, which could be very confusing.