M
Marco Spatz
Hi,
we moved our build platform to the "next" generation (VS 2005 and gcc
4.0) and our code has build (with some minor changes) so far. But now I
met a strange problem with the friend keyword (I know I should be
careful using this ).
I made a reproducer for it:
class ClassA
{
public:
ClassA(void);
~ClassA(void);
protected:
void doA();
void doB();
};
class ClassB
{
friend void ClassA::doA();
public:
ClassB(void);
~ClassB(void);
protected:
void doWonderfulThings();
};
Both compiler (and the comeau online compiler) complain about the
'friend void ClassA::doA();' line for the same reason. They say, that
they cannot access the protected member doA() of ClassA. This hasn't
been a problem with the old compilers. And I know workarounds for this.
But I think this is strange as ClassB isn't accessing doA() but does
only allow it to access all it's member functions (public, protected,
private). I took a look at the standard but haven't found an answer. So
I'm curious. Is this code above legal?
Thanks in advance,
Ciao,
Marco
we moved our build platform to the "next" generation (VS 2005 and gcc
4.0) and our code has build (with some minor changes) so far. But now I
met a strange problem with the friend keyword (I know I should be
careful using this ).
I made a reproducer for it:
class ClassA
{
public:
ClassA(void);
~ClassA(void);
protected:
void doA();
void doB();
};
class ClassB
{
friend void ClassA::doA();
public:
ClassB(void);
~ClassB(void);
protected:
void doWonderfulThings();
};
Both compiler (and the comeau online compiler) complain about the
'friend void ClassA::doA();' line for the same reason. They say, that
they cannot access the protected member doA() of ClassA. This hasn't
been a problem with the old compilers. And I know workarounds for this.
But I think this is strange as ClassB isn't accessing doA() but does
only allow it to access all it's member functions (public, protected,
private). I took a look at the standard but haven't found an answer. So
I'm curious. Is this code above legal?
Thanks in advance,
Ciao,
Marco