c++ - Something like new but to allocate 2 rooms -
i have member function must create 2 objects of class (in memory). must return pointer "p", want access objets p[0] , p[1]. know keyword new, allocate memory 1 object. there similar allocate contigous memory 2 objets ? can create 2 cells array (two pointers) using keyword new 2 times, preferer easier solution (p[0] , p[1]).
myclass * p = new myclass[2];
and remember delete with:
delete[] p;
Comments
Post a Comment