This is not possible or at least not the way you want to it. If you are trying to implement a binary tree-like structure take a look at binary tree this way you have tree structure where you could allocate only what you need dynamically.
if you still need arrays do not use old c style arrays, the c++ committee has been actively updating the standard since 1998 and the modern way of working with arrays is using std::array. If you are working in an evironment where you are working with old C-APIs, write your logic in a modern c++ static library compile it and link against that library in your C-API.
That being said If you are worrying about performance or memory issues, you should reconsider your way of thinking, alot of young developers get caught up in this patterns of thinking and end up writing code that is neither fast nor elegant in terms of design (Its called pessimizing the code). When you write a program first start with readable and simple design, then do profiling and figure out what is slow and should be optimized.
if you really need some of the values in the array to be nulls so you can do crazy stuff with it (such as null checking, which I would highly discourage) you should wrap you integers in another class :
class Integer
{
public:
explicit Integer(int value)
{
value_ = value;
};
Integer &operator=(Integer other)
{
value_ = other.value_;
};
private:
int value_;
};
class test
{
public:
test()
{
Integer four(4);
std::array<std::unique_ptr<Integer>, 2> arr = { std::make_unique<Integer>(four), nullptr};
};
};
NOTE I: What I wrote above is only a trick, so you know everything is possible in c++, however the complexity of what I just wrote to achieve what you wanted, should convince you that its not a good approach for your simple case.
NOTE II: The code is not tested, dont use this as is in production code.