Home |
Temporary Pointers |
Temporary PointersThis type of pointer is used by Window Builder when reference to an object is required after it has been created, but you have not requested an automatic or member pointer to be created. In this case, Window Builder will create a temporary automatic pointer to hold the address of the child object instance. The temporary pointer is called Automatic because it is created on the execution stack, i.e. space for the pointer is allocated automatically by the compiler on the stack, and the space is destroyed when the function (in this case the class constructor) returns. A common example of this might be a PegGroup container added to the top level window. During code generation, Window Builder needs to maintain the address of the PegGroup instance while creating and adding child controls to the group. Window Builder will default to using a temporary pointer for this purpose, which produces the following source code: PegThing * pChild1; pChild1 = new PegGroup(...); // keep temp pointer to object pChild1->Add(..); // add second-generation children to object pChild1->Add(..); // ditto Add(pChild1); // add object to top-level window Window Builder will always use the generic names pChildx for temporary automatic pointers. Window Builder will reuse the temporary pointers for new objects if needed and available during code generation. In some cases, multiple temporary pointers are required simultaneously, in which case Window Builder will create and use as many temporary object pointers as needed.
|