November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 6
Are you thinking about doing your own class-specific memory management, or even replacing C++'s global new and delete? First, try this problem on for size.
The following code shows classes that perform their own memory management. Point out as many memory-related errors as possible, and answer the additional questions.
Consider the following code:
class B
{
public:
virtual ~B();
void operator delete ( void*, size_t ) throw();
void operator delete[]( void*, size_t ) throw();
void f( void*, size_t ) throw();
};
class D : public B
{
public:
void operator delete ( void* ) throw();
void operator delete[]( void* ) throw();
};
Why do B's operators delete have a second parameter, whereas D's do not? Do you ...
Read now
Unlock full access