Hi,
>
> Because it's not a function member.
>
I think my question was not clear.
"Why virtual function cannot be friend ?" is probably the right question.
Here an example :
#include <iostream>
using namespace std;
class A;
class B { public: virtual void print( const A& ) const; };
class C : public B { public: virtual void print( const A& ) const; };
class A {
friend void B::print( const A& ) const;
int a_;
public:
A( int a ) : a_( a ) {}
};
void B::print( const A& a ) const { cout << a.a_ << endl; }
void C::print( const A& a ) const
{ // cout << a.a_ << endl; // cannot access private member
// gcc give a message like virtual cannot be friend.
}
int main() {
A a = 3;
B b;
b.print( a );
}
> -----Message d'origine-----
>
> Because it's not a function member.
>
> >Hi,
> >why friend cannot be virtual member function.
> >I have read the standard but I did not find something
> >about this. ( 10.3 virtual functions and 11.4 Friends )
> >May be the 11.4 point 8 help,
> >it say : "Friendship is neither inherited nor transitive".
> >yes, but why ?
> >
> >Thanks for your help.
> >
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Ce message et ses pi�ces jointes (le "message") est destin� � l'usage
exclusif de son destinataire.
Si vous recevez ce message par erreur, merci d'en aviser imm�diatement
l'exp�diteur et de le d�truire ensuite. Le pr�sent message pouvant
�tre alt�r� � notre insu, CALYON Corporate and Investment Bank
ne peut pas �tre engag� par son contenu. Tous droits r�serv�s.
This message and/or any attachments (the "message") is intended for
the sole use of its addressee.
If you are not the addressee, please immediately notify the sender and
then destroy the message. As this message and/or any attachments may
have been altered without our knowledge, its content is not legally
binding on CALYON Corporate and Investment Bank. All rights reserved.
