Declaring Dynamic 2D Vector in class

前端 未结 4 596
[愿得一人]
[愿得一人] 2021-01-03 05:44

We\'re trying to use a 2D vector because we want a 2D array that will grow dynamically.

We tried this: In the class declaration:

    vector

        
4条回答
  •  感情败类
    2021-01-03 06:30

    You can access the element in [][] manner by derefrencing.

    Vector> *table ;
    table = new vector> ( n, vector( m, 0.0)) ;
    cout << (*table)[i][j] ;
    

    Most of the times, this works perfectly well.

提交回复
热议问题