Note that there are some explanatory texts on larger screens.

plurals
  1. POInherited Class Problems
    primarykey
    data
    text
    <p>I have the next code and i dont know how to solve the mult function. the compiler send me a message cannot declare parameter 'a' to be of type 'Matriz'</p> <p>I'm supposed to use exactly the code that is in the main</p> <p>The message is <strong>cannot declare parameter 'a' to be of type 'Matriz'</strong> </p> <pre><code>enter code here #include &lt;iostream&gt; #include &lt;iomanip&gt; using namespace std; // Base class IMatriz { int **m; int numRows; int numColumns; public: IMatriz(){ numRows = 0; numColumns = 0; m = NULL; } IMatriz(int r, int c) { numRows = r; numColumns = c; m = new int* [numRows]; for(int i=0; i &lt; numRows; i++) m[i] = new int [numColumns]; } virtual void setSize(int r, int c) = 0; virtual void setValue(int row, int col, int val) = 0; virtual int getValue(int row, int col) = 0; virtual int getNumRows() = 0; virtual int getNumColumns() = 0; virtual void mult(IMatriz a, IMatriz b) = 0; virtual void print(void) = 0; }; // Inherited class Matriz : public IMatriz { protected: int **m; int numRows; int numColumns; public: Matriz() : IMatriz() { } Matriz(int r, int c) : IMatriz(r, c) { numRows = r; numColumns = c; m = new int* [numRows]; for(int i=0; i &lt; numRows; i++) m[i] = new int [numColumns]; } void setSize(int r, int c); void setValue(int row, int col, int val); int getValue(int row, int col); int getNumRows(); int getNumColumns(); void mult(Matriz a, Matriz b); void print(); }; // Functions void Matriz::setSize(int r, int c) { numRows = r; numColumns = c; } void Matriz::setValue(int row, int col, int val) { m[row][col] = val; } int Matriz::getValue(int row, int col) { return m[row][col]; } int Matriz::getNumRows() { return numRows; } int Matriz::getNumColumns() { return numColumns; } **void Matriz::mult(Matriz a, Matriz b) {** // m.setSize( a.getNumRows(), b.getNumColumns() ); // for (int rows = 0; rows &lt; numRows; rows ++) // for (int cols = 0; cols &lt; numColumns; cols ++) // m[rows][cols] = 0; // for (int rows = 0; rows &lt; a.getNumRows(); rows ++) // for (int cols = 0; cols &lt; b.getNumColumns(); cols ++) // for (int auxl = 0; auxl &lt; a.getNumColumns(); auxl ++) // m[rows][cols] += (a[rows][auxl] * b[auxl][cols]); return; } void Matriz::print() { for (int rows = 0; rows &lt; numRows; rows ++) { for (int cols = 0; cols &lt; numColumns; cols ++) cout &lt;&lt; m[rows][cols] &lt;&lt; " "; cout &lt;&lt; endl; } } // Principal int main() { Matriz m; Matriz a(3, 2); Matriz b(2, 3); a.setValue(0,0,7); a.setValue(0, 0, 7); a.setValue(1, 0, 1); a.setValue(2, 0, 8); a.setValue(0, 1, 2); a.setValue(1, 1, 5); a.setValue(2, 1, 6); b.setValue(0, 0, 2); b.setValue(1, 0, 3); b.setValue(0, 1, 5); b.setValue(1, 1, 4); b.setValue(0, 2, 8); b.setValue(1, 2, 9); a.print(); b.print(); // m.mult(a,b); // m.print(); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload