I'm having some problems compiling my code. It says,
error C2355: 'this' : can only be referenced inside non-static member functions or non-static data member initializers
part of the code where the error shows up
double getR() {
return this->r;
}
double getG() {
return this->g;
}
double getB2() {
return this->b2;
}
also here
rez.r = this->r / 2 + a.getR() / 2;
rez.g = this->g / 2 + a.getG() / 2;
rez.b2 = this->b2 / 2 + a.getB2() / 2;
Any ideas?
THAT WAS FIXED.
Same error on this part of code now...
rez.r = this->r / 2 + a.getR() / 2;
rez.g = this->g / 2 + a.getG() / 2;
rez.b2 = this->b2 / 2 + a.getB2() / 2;
it also says
error C2227: left of '->r' must point to class/struct/union/generic type
You need to add the class scope to your methods, for example if your class is named YourClass
then your function would be
double YourClass::getR() {
return this->r;
}
Otherwise getR
is a free function, and therefore has no this
to operate on. The same goes for your other methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With