Hey!
I have a class called SparseMatrix which contain a private vector of type Cell.
Cell is a structure that should hold x,y coords and a double value.
In addition, I would like that a different class called RegMatix will be able to declare a vector of type Cell also.
this is the struct:
struct Cell {
Cell(int row,int col, Number value) {
_cellRow = row;
_cellCol = col;
_val = value;
}
int _cellRow, _cellCol;
Number _val;
};
this is sparseMatrix:
class SparseMatrix {
//second, i tried to place the Cell here, but in RegMatrix.cpp Cell was not recognized.
public:
void Iterator(std::vector<Cell>::const_iterator &startElement,
std::vector<Cell>::const_iterator &endElement) const;
private:
std::vector<Cell> _matrix;
//first i tried to place the struct here, but the above line did not recognize
// Cell. then i placed it above the vector and it worked but RegMatrix.cpp did not recognize it.
};
in RegMatrix.cpp i would like to be able to declare:
std::vector<Cell>::const_iterator start,end;
Eventually i placed it out side the class and it works fine, but is this the correct place for this definition?
And one last question, if I want that other classes would be able to read-only the struct data, is struct the correct structure for Cell or should i create a different class called Cell?
Sorry for the long question, Thank you all!