c++ - Using 2d array in a class -
I'm having some problems
1) This is the announcement of 'matrix' as 2D The array border (** mPoint in the header file should be). Why? I want it to be dynamic, how can I fix it?
2) The second problem "mPoint" has not been announced in this scope, in the .cpp file (Squarebattics :: SetStrap). <3> Finally, it says that the definition of the squirrels (Squarebatters :: ~ SquareMatrix) has been declared inherently.
Anything in my C ++ book seems to answer my questions.
// Header File #include & lt; Iostream & gt; using namespace std; Square Square_Matrix {Public: int ** mPoint; Int n Square_Matrix (); ~ Square_Matrix (); Zero set_Size (int new_size); }; //.cpp file # include & lt; Iostream & gt; using namespace std; #include "Square_Matrix.h" SquareMetrics :: SquareMatics () {mPoint = new int * [0]; MPoint [0] = new int [0]; N = 0; } Square_Matrix :: ~ Square_Matrix () // destructor {for (int i = 0; i & lt; n; i ++) {delete} [remove] [md]; } Delete [] mPoint; } Void Square_Matrix :: Set_Size (int new_size) {for (int i = 0; i
You have not declared a destroyer in your class definition, so the compiler has made it clear Declared by the form. Yet you clearly define the district. you can not do.
In the manufacturer you did not initiate mPoint, so the function in your code for example is the undefined behavior of Set_Size.
Comments
Post a Comment