image i have a class called BMPImage. The class looks simplified like this:
data is allocated in the constructor of BMPImage.
BMPImage(const char *filename);
The Matrix class looks like this:
data is aswell allocated in the constructor.
Matrix(const int nRows, const int nCols, const int nChannels);
T get(const int row, const int col);
void set(const int row, const int col, T value);
BMPImage should have much of the same functionality as a Matrix. This would actually be solved by letting BMPImage inherit from Matrix. This is what i actually want to do.
The problem is, that the two constructors look quite different for Matrix and BMPImage.
What would be an elegant way to implement this?
I think of something like this
This would require Matrix to have a default constructor, which would complicate the Matrix class somewhat more than i like to.
class BMPImage : public Matrix<float>
BMPImage(const char *filename)
// read the BMP File
// set nRows, nCols of Matrix accordingly to the BMP file
Another way would be to implement getters and setters in BMPImage which would simply wrap the getters and setters of the Matrix where the BMP Data is stored.
Any ideas on what solution would be more adequate?
Thanks and best regards, threahdead