R
Risto Lankinen
Hi!
Should this compile:
class C
{
private:
void f();
};
class D
{
friend void C::f(); // <- "line 10"
};
int main()
{
return 0;
}
It compiles fine with many compilers, but one compiler rejects
it with the following error:
"test.cpp", line 10: Error: #265-D: function "C::f" is inaccessible
The explanation provided by the error message borders with
reasonable (since C::f after all is a private function, and hence
should be inaddressable by anyone else). Now I'm in doubt
whether this is a bug in said compiler, or if it is an exception
in the access control mechanism. I'm leaning towards a bug
in this compiler since so many others accept it, but then again,
a million flies can't be wrong...
What does the standard say, anyway?
Cheers!
- Risto -
Should this compile:
class C
{
private:
void f();
};
class D
{
friend void C::f(); // <- "line 10"
};
int main()
{
return 0;
}
It compiles fine with many compilers, but one compiler rejects
it with the following error:
"test.cpp", line 10: Error: #265-D: function "C::f" is inaccessible
The explanation provided by the error message borders with
reasonable (since C::f after all is a private function, and hence
should be inaddressable by anyone else). Now I'm in doubt
whether this is a bug in said compiler, or if it is an exception
in the access control mechanism. I'm leaning towards a bug
in this compiler since so many others accept it, but then again,
a million flies can't be wrong...
What does the standard say, anyway?
Cheers!
- Risto -