allocating desired number of rooms in a hotel manaement system
U R trying to allocate memory for your # of rooms.
An example might be:
Code:
#include <malloc.h>
#include <memory.h>
class Blanks
{
public:
Blanks(){}
void *operator new( size_t stAllocateBlock, char chInit );
};
void *Blanks::operator new( size_t stAllocateBlock, char chInit )
{
void *pvTemp = malloc( stAllocateBlock );
if( pvTemp != 0 )
memset( pvTemp, chInit, stAllocateBlock );
return pvTemp;
}
For discrete objects of type Blanks, the global operator new function is hidden. Therefore, the following code allocates an object of type Blanks and initializes it to 0xa5:
Code:
int main()
{
Blanks *a5 = new( 0xa5 ) Blanks;
return a5 != 0;
}
The argument supplied in parentheses to new is passed to Blanks::operator new as the chInit argument. However, the global operator new function is hidden, causing code such as the following to generate an error:
Blanks *SomeBlanks = new Blanks;
Pls let me know if this helps!
;)
Disable Smilies in This Post by Salem