Let’s say I have a class (the name circle was random and has no significance):
Class circle{
double colorFrequency_;
public:
void setColor(double colorFrequency){ colorFrequency_=colorFrequency; }
void setColor(string colorName){ colorFrequency_=colorNameToFrequency(string colorName); }
double getColorFrequency()
string getColorName(){ /* converts color frequency into a string containing the name of a color it's close to, like "red" */ }
}
On one hand, it seems inconsistent to have a method called setColor but not one called getColor, but on the other hand, if I were to instead have functions called setColorFrequency and setColorName, then those names would not be completely descriptive since setColorName would not only affect the output of getColorName, but also the output of setColorFrequency.
Is it too strange to have a function called setColor, but not one called getColor?
It depends on whether you want the member value to be obtained by the users of your class.
So unusual or not, you should stick to what your design demands.