#include <iostream>
using namespace std;
class matrix
{
private:
int a, b;
int r,c;
public:
void set()
{
int row, col, i, j;
r = row;
c = col;
a = i;
b = j;
cin >> row;
cin >> col;
int arr[row][col];
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
cin >> arr[i][j];
}
}
cout << "Display" << endl;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
cout << arr[i][j] << " ";
}
cout << endl;
}
}
virtual void get()
{
cout << "Class";
}
};
class derived : public matrix
{
void get()
{
cout << "This is virtual fun";
int r, c, a, b;
cin >> r;
cin >> c;
int arr[r][c];
for (a = 0; a < r; a++)
{
for (b = 0; b < c; b++)
{
cin >> arr[a][b];
}
}
cout << "Display" << endl;
for (a = 0; a < r; a++)
{
for (b = 0; b < c; b++)
{
cout << arr[a][b] << " ";
}
cout << endl;
}
cout << "Sum Display" << endl;
for (a = 0; a < r; a++)
{
for (b = 0; b < c; b++)
{
arr[a][b] = arr[a][b] + arr[a][b];
cout << arr[a][b] << " ";
}
cout << endl;
}
}
};
;
int main(int argc, char const *argv[])
{
matrix *ptr;
derived d;
ptr = &d;
ptr->get();
ptr->set();
return 0;
}
Post a Comment
If you have any doubts. Please Let me Know