This is a C ++ class that I made with n number of pointers.
class SomeClass { private: int* ptr1; int* ptr2; ... int* ptrn; private:
At the initialization stage, I want all of these pointers to point to NULL (or pointers to point to NULL by default when they are declared), and not do this:
void SomeClass::MakePtrNull() { ptr1 = NULL; ptr2 = NULL; ... ptrn = NULL; }
Is there an easy way to achieve this? I'm just wondering if there are ways to avoid entering n lines ptr = NULL; in my function. Thanks in advance.
ADDED based on the answers I have received so far: Unfortunately, these pointers must be separate, as they are used for different purposes. I made pointer names as such to indicate exactly what I'm trying to do, but each pointer has a completely different purpose. I think I would have to point out that they point to NULL, as I already did. Thank you for your responses.
c ++ pointers
stanigator
source share