C++ pointer to a pointer to an array consisting of n elements -
c++ how initialize pointer:
int (**alines)[2] ? i'm trying initialize:
int (**alines)[2] = (int(**)[2]) new int*[10]; for(int = 0; < 10; i++){ alines[i] = new int[5][2]; }
in c++, vector should default choice of container. naked new's should avoided well. avoid dynamically allocating objects unless necessary. following these guidelines result in code safer , easier maintain.
here's how make vector of ints, pointer said vector, , pointer said pointer.
std::vector<int> v = {3,8,1,6}; std::vector<int>* p = &v; std::vector<int>** pp = &p; std::cout << p->front() << std::endl; std::cout << (*pp)->back() << std::endl; i'm not sure you're trying in code have shown, there's better way. if describe you're trying achieve can more.
Comments
Post a Comment