I am calculating how long one person can get sunburn with screen protection. As I like to use different approach to do things, I created a class called SunscreenSPF.
class SunscreenSPF
{
private:
string skinColor;
int SPF;
int time;
public:
SunscreenSPF(string skinColor, int SPF, int time)
{
this->skinColor=skinColor;
this->SPF=SPF;
this->time=time;
}
int calculateTime ()
{
return SPF*time;
}
friend ostream& operator<<(ostream &os, const SunscreenSPF &data)
{
os<<"Skin Color = "<<data.skinColor<<endl
<<"Time outdoors = "<<data.time<<endl
<<"SPF Level = "<<data.SPF<<endl
<<"Time to get sunburn with protection = "<<data.calculateTime()<<endl;
}
};
I get this error: passing 'const SunscreenSPF' as 'this' argument discards qualifiers [-fpermissive]|
How can I fix this?
osfrom theoperator<<function, else you'll encounter a warning. - Zoso