Hello. I'm a newbie and i was wondering if anyone can tell me how to create an array that contains objects and number 0 wherever there is no object. Thanks in advance

Recommended Answers

All 2 Replies

I think you might be talking about an array of pointers to some objects, and the pointers are NULL if it does not contain valid pointer. Something like this:

class MyClass
{
   // blabla
};

// an array of 10 pointers to MyClass objects, 
// initialized to NULL pointers.
MyClass* array[10] = {NULL};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.