On Tue, 2 Mar 1999, Neil Davidson wrote:

> Hi,
> 
> > Try allocating the array like this:
> > 
> > Film*       filmArray = new Film[Max_Film_Num];
> > 
> > Don't forget to explicitly delete the array as well...
> 
> Sorry to be such an annoying newbie, but how do I explicitly delete it?

        delete[] filmArray;

> And how do I "dynamically allocate" room for the name etc fields, rather
> than declare char name[50] for example?

        struct Foo {
                char * name;
        };

        Foo * bar = new Foo[3];
        bar[0].name = new char[20];
        // ...
        delete[] bar[0].name;
        delete[] bar;

It gets fairly tediuous to allocate each field like this, so the
allocation and decallocation of individual elements would normally be put
in the constructor and destructor of a class.

All of this stuff will be described in an introductory C++ book (and a
different mechanism will be described for C), and none of this is specific
to PalmOS.

> Many thanks (again),
> 
> Neil

-- 
Kenneth Albanowski ([EMAIL PROTECTED], CIS: 70705,126)


Reply via email to