Using New

After verifying that the <className> class object exists, the <className>New macro invokes the somNew method on the class object. This allocates enough space for a new instance of <className>, creates a new instance of the class, initializes this new object by invoking somDefaultIniton it, and then returns a pointer to it. The <className>Newmacro automatically creates the the class object for <className>, as well as its ancestor classes and metaclass, if these objects have not already been created.

After a client program has finished using an object created using the <className >New macro, the object should be freed by invoking the method somFree on it:

   _somFree(obj);

After uninitializing the object by invoking somDestruct on it, somFree calls the class object for storage deallocation. This is important because storage for an object created using the <className>New macro is allocated by the class of the object. Thus, only the class of the object can know how to reclaim the object's storage. object for storage deallocation.


[Back: Creating instances of a class]
[Next: Using Renew]