class A {
private:
B* my2DArray[max1][max2];
};
How to initialize my2DArray with NULL here?
Define your own constructor that value initializes the array, setting all of its elements to null pointers. That's done by providing ()
initializer for the member, which also works for arrays.
class A
{
public:
A():my2DArray() { }
private:
B* my2DArray[max1][max2];
};
You could use memset:
memset(&my2DArray, 0, max1*max2*sizeof(B*));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.