1. Write the output of the following program
Class ABC;
Void del (ABC * pobj ){
Delete pobj;
}
Class ABC {
Public:
ABC (){
Printf ("ABC/R/N ");
}
~ ABC (){
Printf ("~ ABC/R/N ");
}
};
Int main ()
{
ABC * pobj = new ABC;
Del (pobj );
}
2. Write the output of the following program
Void * operator new (size_t size)
{
Printf ("malloc % u/R/N", size );
Return malloc (size );
}
Void operator Delete (void * memblock ){
Printf ("Free/R/N ");
Return free (memblock );
}
Class ABC {
Public:
ABC (){
Printf ("ABC/R/N ");
Throw int ();
}
~ ABC (){
Printf ("~ ABC/R/N ");
}
};
Int main (){
Try {
New ABC;
} Catch (Int & I ){
Printf ("% d/R/N", I );
}
Return 0;
}
3. Write the output of the following program
Template <typename T>
Class ABC {
Public:
ABC (){
Printf ("Primary/R/N ");
}
};
Template <>
ABC <int>: ABC (){
Printf ("member spec/R/N ");
};
Template <typename T, typename P>
Class ABC <t (*) (p)> {
Public:
ABC (){
Printf ("partial spec/R/N ");
}
};
Int main ()
{
ABC <void * (*) (INT)> f_abc;
ABC <int> I _abc;
}
4. Can the following code be compiled? Why?
Class {
Public:
Virtual ~ A (){
}
PRIVATE:
Void operator Delete (void * P );
};
Int main ()
{
A _ 1;
}