Yes, you can certainly do that in C++.
No, there isn't anything built in that will do it for you ready made.
As CPallini indicated, it will require the use of dynamic memory allocation.
There was a somewhat related question recently. Based on that, here is a possible starting point. Beware this is off-the-cuff with no attempt to compile. It contains no error checking. It may even contain glaringly obvious errors.
template<typename T>
class multiDimArray
{
public:
multiDimArray( const std::vector<size_t> &dimensions ) :
dimensions_( dimensions ), pContents(NULL);
{
size_t size = 1;
std::vector<size_t>::const_iterator dimIter = dimensions_.begin();
for ( ; dimIter != dimensions_.end(), ++dimIter )
{
size *= *dimIter;
}
pContents = new T[ size ];
}
~multiDimArray( )
{
delete [] pContents;
}
T& operator()( const std::vector<size_t> &indicies )
{
std::vector<size_t>::const_iterator indexIter = indicies.begin();
std::vector<size_t>::const_iterator dimIter = dimensions_.begin();
size_t offset = 0;
++dimIter;
for ( ; dimIter != dimensions_.end(); ++dimIter, ++indexIter )
{
offset += *indexIter;
offset *= *dimIter;
}
offset += *indexIter;
return *(pContents + offset);
}
std::vector<size_t>size_type NumberOfDimensions() const
{
return dimensions_.size();
}
private:
T *pContents;
std::vector<size_t> dimensions_;
};