Newsgroups: comp.os.msdos.djgpp From: Twan Jans-Beken Subject: Re: Assembly routines with C++ X-Nntp-Posting-Host: pc1-jabe Content-Type: text/plain; charset=us-ascii Message-ID: <37A038DC.779548AD@oce.nl> Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl) Content-Transfer-Encoding: 7bit Organization: Oce-Technologies B.V. - Research & Development X-Accept-Language: en References: <19990726135211 DOT 18814 DOT rocketmail AT send205 DOT yahoomail DOT com> Mime-Version: 1.0 Date: Thu, 29 Jul 1999 11:19:57 GMT X-Mailer: Mozilla 4.6 [en] (Win95; I) Lines: 95 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I am not shure that I understand exactly what your problem is, but I gues that you mean that main.c and gui.c want to call line WITHOUT the last parameter. In that case a solution is simple... --- 8< FIRST SOLUTION >8 --- Suppose you have a class SCREEN: class SCREEN { private: BUFFERTYPE buffer; ... public: void line(int x1, int y1, int x2, int y2, void *back = &buffer); ... } In this manner you can call line with 4 and 5 parameters. From gui.c and main.c you can call line with only 4 parameters. They can call line also with 5 parameters but then they must define their own buffer. --- 8< SECOND SOLUTION >8 --- Suppose you have a class SCREEN: class SCREEN { private: BUFFERTYPE buffer; void private_line(int x1, int y1, int x2, int y2, void *back = &buffer); ... public: void line(int x1, int y1, int x2, int y2) { private_line(x1,y1,x2,y2,&buffer); } ... } In this manner you make only the four-parameter version available to the other classes. The five-parameter version is only available to the SCREEN class. Note: I have never tested my solutions, so they may need some expert review. Mohamed Saad wrote: > Hi All, > How are u? hope all is ok! ;) > > well... i am currently switching from C to C++! I > have a C program that i want to transform into > object-oriented approach! but i have one simple (I > hope! :)) question! > > I had an .asm file compiled and linked with my > program! This file contained a function called > line()... here is its prototype... > > void line(int x1,int y1,int x2,int y2,char color,void* > back); > > well... back is the back buffer.... and it is global! > > line() was called from several other parts in my > program... (e.g. in gui.c and in main.c!) > > well... now, to make it into object oriented, the > function line should be a member of the Class called > 'screen'! the back buffer also should be a member of > the 'screen' Class... > > So... where is the problem? > well... other objects (e.g. gui) should NOT have > access to the backbuffer data structure! OOP > principles are clear! Classes should never export data > structures! it should export a method to modify this > data structure... > so... back will be hidden from other classes!! they > will not be able to call line()! > > so... is there a way so that i can make the .asm file > *see* the member back of the Class called 'screen'? so > that it can modify it? line() is a member of the > class... but, how can i persuade the *assembler* (NASM > btw!!)... > > Any suggestions are welcome! Thanx in advance! > > URS forever, > Mohamed El Dawy > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com