S
Suraj
Can someone suggest me a way of never returning a NULL pointer.
Say I have a class
class X
{
int x;
X();
int GetValue(){return x;}
};
I am allocating memory for this structure dynamically. I want to
implement a GetPointer method which returns the pointer to the
allocation memory.
something like:-
ptr = GetPointer();
Its possible that the allocation failed, Its OK for me. Now throughout
the code i need to check for (ptr!=NULL) before using it.
I want to avoid this.
Say I have a class
class X
{
int x;
X();
int GetValue(){return x;}
};
I am allocating memory for this structure dynamically. I want to
implement a GetPointer method which returns the pointer to the
allocation memory.
something like:-
ptr = GetPointer();
Its possible that the allocation failed, Its OK for me. Now throughout
the code i need to check for (ptr!=NULL) before using it.
I want to avoid this.