If a class has a constructor it is executed when an object of that class is created. This constructor typically initializes the state of the object. Foundation Classes' constructors often have mandatory positional parameters that the programmer must provide at object creation time.
C++ objects can be created in one of two ways:
{
ClassX objX
ClassY objY(parameter1);
} //objects deleted here
{
ClassX* pObjX = new ClassX;
ClassY* pObjY = new ClassY(parameter1);
} //objects NOT deleted here
{
ClassX* pObjX = new ClassX;
ClassY* pObjY = new ClassY(parameter1);
·
·
·
pObjX->method1();
pObjY->method2();
·
·
·
delete pObjX;
delete pObjY;
}
Most of the samples in this book use automatic storage. You are advised to use automatic storage, because you do not have remember to explicitly delete objects, but you are free to use either style for CICS® C++ Foundation Class programs. For more information on Foundation Classes and storage management see Storage management.
[[ Contents Previous Page | Next Page Index ]]