I have a class which allows me to access a vectors value:
Class Image{
public:
Image(int rows, int cols): cols_(cols), rows_(rows), data_(rows*cols,0) {};
int& at(int row, int col){
return data_.at(col*row);
};
private:
int rows_ = 0;
int cols_ = 0;
const int max_val_ = 255;
std::vector<int> data_;
Currently this lets me perform
int num = image.at(row, col);
// or
image.at(row, col) = 10;
My question is how to I limit the values of data_
to not allow an assignment more than max_value_
? I.e image.at(row,col) = 256;