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?
https://stackoverflow.com/questions/66757358/error-passing-const-sunscreenspf-as-this-argument-discards-qualifiers-issue March 23, 2021 at 12:40PM
没有评论:
发表评论