#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;
cout << "Enter Row Number" << endl;
cin >> row;
cout << "Enter Col Number" << endl;
cin >> col;
int arr[row][col];
cout << "Enter Col Numbers and Row Numbers:-" << endl;
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;
}
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;
}
}
virtual void get()
{
cout << "Class";
}
};
class derived : public matrix
{
public:
void set();
void get()
{
matrix::set();
}
};
;
int main(int argc, char const *argv[])
{
matrix *ptr;
derived d;
ptr = &d;
ptr->get();
return 0;
}
Post a Comment
If you have any doubts. Please Let me Know