How to dynamically allocate an array of pointers in C++?

后端 未结 3 1927
臣服心动
臣服心动 2020-12-10 15:35

I have the following class

class Node
{
    int key;
    Node**Nptr;
public:
    Node(int maxsize,int k);
};
Node::Node(int maxsize,int k)
{
   //here i wan         


        
3条回答
  •  [愿得一人]
    2020-12-10 15:41

    Suppose you want to create matrix of 3 rows and 4 cols then,

    int **arr = new int * [3];  //first allocate array of row pointers
    
    for(int i=0 ; i

提交回复
热议问题