I really need help with this class I'm in. I understand the basic principles behind the classes, but I'm unsure how to translate what I want to do into code. On one particular project I need to create a user defined matrix, and then give the user the option to add, subtract, multiply, or print the matrix. We are supposed to use classes, but I don't know how to create the classes. I don't know if they go in the header file or the cpp file. I haven't used C++ in 4 years and I'm totally lost. I'm including what I have so far, so if anyone can give me any advice, i would be thankful.
code:
header file
__________________________________________________
Code:
#ifndef MATRIXTYPE_H_
#define MATRIXTYPE_H_
#include <fstream>
#include <iostream>
const int MAX_ROWS = 10;
const int MAX_COLS = 10;
class MatrixType
{
public:
MatrixType();
void MakeEmpty();
void SetSize(int rowSize, int colSize);
void StoreItem(int item, int row, int col);
void Add(const MatrixType& otherOperand, MatrixType& result);
void Sub(const MatrixType& otherOperand, MatrixType& result);
void Mult(const MatrixType& otherOperand, MatrixType& result);
void Print(std::ofstream& outfile);//Also echo print to console
bool AddSubCompatible(const MatrixType& otherOperand);
bool MultCompatible(const MatrixType& otherOperand);
private:
int values[MAX_ROWS][MAX_COLS];
int numRows;
int numCols;
};
#endif
__________________________________________________ __
.cpp file
__________________________________________________ __
Code:
#include “MatrixType.h"
int main()
{
bool done=false;
MatrixType TheMatrix[10];
//Initialize the program as needed
while(!done)
{
//Print menu choices
//InitMatrix(index), sets number of rows and columns
//AddMatrices(indexleft, indexright, indexresult)
//SubMatrices(indexleft, indexright, indexresult)
//MultiplyMatrices(indexleft, indexright, indexresult)
//PrintMatrix(index)
//Quit
//Get input
//Perform task
}
return 0;
}
__________________________________________________ _