make getters const

This commit is contained in:
Shuo Feng 2024-02-27 21:23:24 -05:00
parent 94f1898b51
commit 43a8204032
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1
2 changed files with 7 additions and 7 deletions

View file

@ -10,13 +10,13 @@ void Output::write() {
for (unsigned int x = 0; x < width; ++x) for (unsigned int x = 0; x < width; ++x)
fout << (char)(255.0f * red[y * width + x]) fout << (char)(255.0f * red[y * width + x])
<< (char)(255.0f * green[y * width + x]) << (char)(255.0f * green[y * width + x])
<< (char)(255.0f * blue[y * width + x]); << (char)(255.0f * blue[y * height + x]);
fout.close(); fout.close();
} }
float Output::r(int index) { return red.at(index); } float Output::r(int index) const { return red.at(index); }
float Output::g(int index) { return green.at(index); } float Output::g(int index) const { return green.at(index); }
float Output::b(int index) { return blue.at(index); } float Output::b(int index) const { return blue.at(index); }
void Output::r(int index, float value) { red.at(index) = value; } void Output::r(int index, float value) { red.at(index) = value; }
void Output::g(int index, float value) { green.at(index) = value; } void Output::g(int index, float value) { green.at(index) = value; }
void Output::b(int index, float value) { blue.at(index) = value; } void Output::b(int index, float value) { blue.at(index) = value; }

View file

@ -27,11 +27,11 @@ private:
public: public:
void r(int, float); void r(int, float);
float r(int); float r(int) const;
void g(int, float); void g(int, float);
float g(int); float g(int) const;
void b(int, float); void b(int, float);
float b(int); float b(int) const;
}; };
#endif // !OUTPUT_H_ #endif // !OUTPUT_H_