Accessing the 2D array in a Matrix class (C++) (Visual Studio 2010) -


i relatively new programming student , new c++ please bear me while struggle sort through this.

i trying make matrix class few basic functions change it. objects created in matrix class should 100x100 2d array of floats. should able change value @ particular location in array value. relevant code follows:

    //in .h file     class matrixc     {     private:        float matrix[100][100];      public:        void initializematrix(matrixc);        void printmatrix(matrixc);        void setvalue(matrixc, float, int row, int column);        float getvalue(matrixc, int row, int column);     }     //in .cpp file    void setvalue(matrixc matrix, float value, int row, int column)    {       matrix[row][column] = value; //error line    } 

i getting following error @ line indicated above, first bracket in line highlighted: "matrixc matrix - no operator '[]' matches these operands."

i error regarding "=" in same line.

after googling, not life of me figure out how fix issue regarding "[]". issue regarding "=" seems because compiler thinks "matrix[row][column]" , "value" different data types, both referring floats. suspect problem fixed once problem "[]" fixed.

am accessing 2d array inside matrixc class improperly? if so, have no idea how properly. if not, have no clue issue is.

you using matrix object array, not. if want use [] operator, should overload it. more on overloading here

if not wish overload operator, should create function returns actual array member (or make public) , change value.

by way, think might wanna change function signature matrix variable, , pointer object allow actual change , not copy of sent object. read more references , pointers understand.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -