delorie.com/archives/browse.cgi | search |
From: | Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p> |
Newsgroups: | comp.os.msdos.djgpp,comp.lang.c++ |
Subject: | Re: OOP in DJGPP- Sharing member functions |
Organization: | Pin Eight Software http://pineight.8m.com/ |
Message-ID: | <lsdsos8m5evprtukmifeulu8e59f92bvlu@4ax.com> |
References: | <398CB99E DOT 893B71C9 AT addr DOT com> |
X-Newsreader: | Forte Agent 1.7/32.534 |
MIME-Version: | 1.0 |
Lines: | 74 |
X-Trace: | +SHLvkCNrw2VICYdDKC/e3ztfCSM7s8iM0mWpB5twBXZgjJ/H3MS02mDf43ru4FFr/VjgAb2YHmt!u0wixXEBOnkITFUa0LcGJ5QRJ/WdObD0mvgh2m5DVR1aJGJ42H80gYjnJC0H6ylY8SDA6R/oW/5H!qLU= |
X-Complaints-To: | abuse AT gtei DOT net |
X-Abuse-Info: | Please be sure to forward a copy of ALL headers |
X-Abuse-Info: | Otherwise we will be unable to process your complaint properly |
NNTP-Posting-Date: | Mon, 07 Aug 2000 04:14:09 GMT |
Distribution: | world |
Date: | Mon, 07 Aug 2000 04:14:09 GMT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
On Sat, 05 Aug 2000 18:04:30 -0700, Ardy Falls <ardy AT addr DOT com> wrote: >Hi, I was wondering how to make two classes share a function member >where BOTH classes can call that function. I tried it with the friend >operator but it did not work. >here is an example of what I'm trying to do... There is that actual code >below the diagram. Look up the friend keyword. It can expose a private or protected method or field to another particular class. I'll refer you to comp.lang.c++ for a full explanation. > thanks a million, > ardy > http://www.addr.com/~ardy/ > > [-----object >1---------] >[----object 2---------] > [ void set_pos(void); ] ---- thay share the same function------> [ >void set_pos(void); ] > [-----------------------] >[ ---------------------] > >[----- main------------] >[ object 2.set_pos(); ] >[----------------------] > > >----------------------------here is the actual >code------------------------------- > >#include <iostream.h> > >class baseclass { > protected: > long HANDLE; > public: > void ActionProc(void); >}; >void baseclass::ActionProc(void){ > cout<<"ActionProc Sucsesfully Called"<<endl; >}; > >class otherclass { > protected: > long HANDLE; > public: > friend void baseclass::ActionProc(void); >}; > >class ourclass:baseclass { > public: > otherclass a; > void callit(void); >}; >void ourclass::callit(void) { > a.ActionProc(); >} >void main(void) { > ourclass b; > b.callit(); >} > -- Damian Yerrick "I refuse to listen to those who refuse to listen to reason." See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your signature to prevent the spread of signature viruses. http://www.mcafee.com/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |