Hi,
>
> As I think, because Virtual Function could be overloaded, so making
> it as friend is an undefined action. Which virtual fucntion will of
> the derived calsses would get the friendship access?
>
in fact this was the only reason that come to my mind too.
As anyone can inhereted from a class this can be risky.
> Again, this is my guess, and I think there should be a technical
> reason which stops this friendship.
I have no clue about this one.
thanks.
> Regards.
>
>
> --- In [EMAIL PROTECTED], David Fleury <david.fleury-
> [EMAIL PROTECTED]> wrote:
> > 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.
> > > >
> >
> > 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.
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> $9.95 domain names from Yahoo!. Register anything.
> http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/EbFolB/TM
> --------------------------------------------------------------
> ------~->
>
> To unsubscribe, send a blank message to
> <mailto:c-prog-> [EMAIL PROTECTED]>.
> 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:
> http://docs.yahoo.com/info/terms/
>
>
>
>
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.
