The code below gives error: error: ‘double& Sample::GetValue()’ is protected within this context | double v = ms.GetValue();
. If the protected function if deleted it compiles fine. Is it the bug of the compiler that cannot select the correct function overload with different scope?
class Sample
{
public:
Sample() {}
virtual ~Sample() {}
const double& GetValue() const {return v;}
void Print() {std::cout << v << std::endl;}
protected:
double& GetValue() {return v;}
private:
double v;
};
class Sample2
{
public:
Sample2() {}
void Compute()
{
double v = ms.GetValue();
}
private:
Sample ms;
};