| delorie.com/archives/browse.cgi | search |
| Message-ID: | <398CB99E.893B71C9@addr.com> |
| From: | Ardy Falls <ardy AT addr DOT com> |
| X-Mailer: | Mozilla 4.74 [en]C-CCK-MCD NSCPCD47 (Win98; U) |
| X-Accept-Language: | en |
| MIME-Version: | 1.0 |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | OOP in DJGPP- Sharing member functions |
| Lines: | 58 |
| Date: | Sat, 05 Aug 2000 18:04:30 -0700 |
| NNTP-Posting-Host: | 63.196.4.63 |
| X-Complaints-To: | abuse AT pacbell DOT net |
| X-Trace: | news.pacbell.net 965523950 63.196.4.63 (Sat, 05 Aug 2000 18:05:50 PDT) |
| NNTP-Posting-Date: | Sat, 05 Aug 2000 18:05:50 PDT |
| Organization: | SBC Internet Services |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
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.
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();
}
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |