1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#include <conio.h>
class matrik
{ private:
int vMatrik[100];
int row, col;
char Name;
public:
matrik(){
}
~matrik() {;}
void newValue( … ) {
}
void setName( … ) {
}
void setDimensi( ) {
}
void clear() {
}
void print() {
}
matrik operator +( ) {
}
matrik operator -( ) {
}
void operator -() {
}
matrik operator *( ) {
}
};
int main()
{
const row_data1 = 3, col_data1 = 3;
const row_data2 = 3, col_data2 = 4;
int data1[10][10] =
{ {1, 2, 3},
{4, 5, 6},
{7, 8, 9}};
int data2[10][10] = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 0, 1}};
matrik *pA = new matrik(row_data1, col_data1, 'A');
matrik *pB = new matrik(row_data2, col_data2, 'B');
matrik *pC = new matrik(row_data1, col_data1, 'C');
cout << "Test the initial value of all objects are 0\n";
pA -> print();
pB -> print();
pC -> print();
cout << "Press any key...";
getch();
clrscr();
cout << "Test provision of new value\n";
pA -> newValue(data1);
pB -> newValue(data2);
pA -> print(); pB -> print();
pC -> print();
cout << "Press any key...";
getch();
clrscr();
cout << "The summing operation test : C = A + A\n";
cout << "initial contents of the data\n";
pA -> print();
pC -> print();
*pC = *pA + *pA;
pC -> setName('C');
cout << "operating results\n";
pA -> print(); pC -> print();
cout << "Press any key...";
getch();
clrscr();
cout << "Test subtraction operation: A = A - C\n";
cout << "initial contents of the data\n";
pA -> print();
pC -> print();
*pA = *pA - *pC;
pA -> setName('A');
cout << "operating results\n";
pA -> print();
pC -> print();
cout << "Press any key...";
getch();
clrscr();
cout << "Test operation of negation: -A.\n";
cout << "initial contents of the data\n";
pA -> print();
-*pA;
cout << "operating results\n";
pA -> print();
cout << "Press any key...";
getch();
clrscr();
cout << "Test operation of multiplication: C = A x B\n";
pC -> setDimensi(row_data1, col_data2);
pC -> clear();
cout << "initial contents of the data\n";
pA -> print();
pB -> print();
pC -> print();
*pC = *pA * *pB;
pC -> setName('C');
cout << "operating results\n";
pC -> print();
cout << "Success...";
delete pA;
delete pB;
delete pC;
getch();
return 0;
}
|