CAlive will introduce mated constructor and destructor pairs allowing class instances to receive a custom destructor, with the ability to call the
default() constructor as needed.
class CExample
{
public:
CExample(int a)
{
// constructor code here
printf("int constructor\n");
} ~ {
// mated destructor code here
default();
printf("Mated destructor\n");
}
CExample(s8* tcText)
{
// constructor code here
printf("s8* constructor\n");
} ~ {
// mated destructor code here
printf("Mated destructor\n");
default();
}
CExample(f32 f)
{
// constructor code here
printf("f32 constructor\n");
} ~ {
// mated destructor code here
printf("f32 destructor\n");
}
// Normal destructor
~CExample()
{
}
};
function main
| params int argc, char* argv[]
| returns int r
{
CExample e1(5);
CExample e2("Hello");
CExample e3(1.2f);
printf("\n");
r = 0;
}
The output of the above program would be:
int constructor
s8* constructor
f32 constructor
int destructor
int mated destructor
s8* mated destructor
s8* destructor
--
Rick C. Hodgin