Quote:
a. Create a class named Matrix2x2 having four floating point data members named n1, n2, n3, n4. The class's default constructor should provide data members with default values of 1 if no explicit user initialization is provided. Additionally, provide member functions for displaying an object's data values and for calculating the determinant (see below). Also provide the class with an overloaded operator function that is capa¬ble of multiplying two Matrix2x2 objects according to the following procedure:
example of Matrix2x2 : | n1 n2 |
| n3 n4 |
multiplication:
|n1 n2| |N1 N2| |n1N1 + n2N3 n1N2 + n2N4|
|n3 n4| x |N3 N4| = |n3N2 + n4N4 n3N2 + n4N4|
determinant of |n1 n2| = n1n4 – n3n2
|n3 n4|
b. Include the class in a working C++ program that tests each of the class's member functions.
|
Code:
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
class Matrix2x2
{
private:
float n1;
float n2;
float n3;
float n4;
public:
Matrix2x2(int = 1. int = 1, int = 1, int =1);
void calcDet();
Matrix2x2 operator*();
};
Matrix2x2::Matrix2x2(int nOne, int nTwo, int nThree, int nFour)
{
n1 = nOne;
n2 = nTwo;
n3 = nThree;
n4 = nFour;
}
void Matrix2x2::calcDet()
{
}
Matrix2x2 Matrix2x2::operator*()
{
}