In: Computer Science
What are the “guard statements” that we put in the .h file of a class definition? Also tell what each of them do.
______________________________________________________________________________________________
What keywords are used to create, and release dynamic memory?
________________________________________________________________________________________
What is being made constant in the following member function of a Monkey class? Explain what each const is doing.
const Zip& frappa( const Foo& thing ) const;
_________________________________________________________________________________________
Thank you for the explain these problems.
Header Guard's main purpose is to not letting the implemention of same function from header files multiple times in a same program ,like let two header file be A and B and B includes all the Functions for A . Now in a Program both of them are used so , in this case , due to header guards only once functions of A will be included ,not twice.Some comman Header Guards are-
#ifndef,which ends with #endif,Its purpose is to see the macro defined in it should not a pre defination if it does then it does not overwrites the predefination og the macro and thus prevents multiple values of a comman macro.
------------------------------------------------------------------------------------------------------------------------------------------------------
In C++ "new" keyword is use to create and "delete" keyword is used to delete dynamic memory
------------------------------------------------------------------------------------------------------------------------------------------------------
The first "const Zip&" is used to referance a constant pointer variable.
The Middle one is used to make the arguments constent of function frappa.
The last const is used to make the member function of this class Constant.
-------------------------------------------------------------------------------------------------------------------------------------------------------
Apologies if i was not able to explain something properly or if something is incorrect.