#include <iostream>
using namespace std;
class metrix
{
public:
int row, col, i, j,sum,arr[10][10];
void get(){
cout<<"Enter Row Number";
cin >> row;
cout<<"Enter Col Number";
cin >> 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 sumdiplay() = 0;
};
class derived : public metrix
{
public:
void get(){};
virtual void sumdiplay(){
cout << "Sum Display" << endl;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
arr[i][j] = arr[i][j] + arr[i][j];
cout << arr[i][j] << " ";
}
cout << endl;
}
};
};
int main()
{
metrix *ptr;
derived derivedobj;
ptr = &derivedobj;
ptr->get();
ptr->sumdiplay();
return 0;
}
Post a Comment
If you have any doubts. Please Let me Know