--------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00043 Date: 09/16/97 From: CHRIS DOWNS Time: 07:03am \/To: ROGER SCUDDER (Read 2 times) Subj: Re: Worked this out KK> class MathCalc KK> { KK> private: KK> int iVar1, iVar2, iResult; RS> Why do you code the private keyword when the data is private RS> by default. Is this considered good style? I like to stick in the private. But then again, I like to put my private sections of the class _last_ in the source header. It's the public sections that are of most interest to the clients of the class. Theorectically at least, the private sections are of no interest to the user of the class. --- Blue Wave/QWK v2.12 * Origin: St. Louis Users Group (1:100/4) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00044 Date: 09/16/97 From: CHRIS DOWNS Time: 05:27pm \/To: DARIN MCBRIDE (Read 2 times) Subj: Re: WHY THE BRACES? DM> Single entry. Single exit. Flow always goes DM> down, except in properly DM> defined structural loops (while, do while, for). Clean-up code will DM> always get executed. Adding extra clean-up code will not break DM> anything - it will also get executed every time because it is part of DM> the single exit. CD> Yeah... I've seen such things. It's not the only way to do it. CD> Nor are alternative methods (IMO) "less readable". DM> Without writing every pointer-resource into classes, I've been hard DM> pressed to find other ways of doing it. Perhaps an example, Chris? I must be missing something as this sounds like pretty basic stuff to me. All you need do is create an appropriate class and we can get the same "will also get executed every time" functionality via a destructor rather than using gotos as a funnel to some shared code section. You could be making a better case for the example you've described over on the C echo. DM> Often writing a dozen small classes DM> that handle resources is less readable than the goto. I would submit that if you needed a dozen small classes to avoid the goto, then the goto (or lack thereof) is not the problem. --- Blue Wave/QWK v2.12 * Origin: St. Louis Users Group (1:100/4) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00045 Date: 09/16/97 From: CHRIS DOWNS Time: 05:27pm \/To: ROGER SCUDDER (Read 2 times) Subj: Re: Worked this out RS> My question is, if the data is private RS> and it is at the top, before any access specifiers, why RS> would you place a private tag before it, when the access RS> is already private by default? Leading off the class definition with 'private' is certainly useless in the added functionality department. But even if you lead off your class with private stuff, I think it's a good idea to have the private label. For one thing, it's much more common for a class to be layed out with public members first. If you are going to be different, it's probably a good idea to make it as explicit as possible that you are doing it differently. --- Blue Wave/QWK v2.12 * Origin: St. Louis Users Group (1:100/4) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00046 Date: 09/16/97 From: DANIEL HEBBERD Time: 01:44pm \/To: ALL (Read 2 times) Subj: sorry Look , someone is fiddleing with my account , if any dumb stuff starts apearing about me , please ignore it , if anything goes by the name JINK and sounds like a load of crap , please ignore it and inform me ! Im sorry for any inconveniance ... Have a nice day ... :) (heheheh dumb letter eh , but the contents is compleatly factual , no crap) -=- daniel hebberd -=- jink -=- --- Renegade v666 dMp * Origin: dMp ][, Man can not live on Toons alone... (3:774/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00047 Date: 09/17/97 From: CLIFF RHODES Time: 10:35am \/To: JAMIE KOWINSKY (Read 2 times) Subj: cout'ing an object --> Jamie Kowinsky wrote to All <-- JK>say I have a class defined, lets call it class test, this class has JK>a number of private variables and public functions. It includes a JK>function to print out some private data fileds ex "void JK>test:print(void)" this function simply does "cout << stuff" on a JK>number of things, in effect printing the fields of the object. JK> JK>Now say i have some object created with this class ex: JK>test thing = test(....); JK>normally to print this thing i have to call "thing.print" I would JK>rather do a "cout << thing". I am fimular with overloading JK>operators, and I would like to know if its possible to overload the JK><< operator somehow to do this. Or perhaps there is another way. You bet, overloading << is an important C++ ability. // I did not test this code, but it should be close... #include class test { private: // Aside: yes, Neil, I explicitly do this! int a; const char *s; public: // Constructor with default arguments test(int i = 1, const char *str = "No String") : a(i), s(str) { } // This is how to overload << friend ostream & operator << (ostream & os, test & t) { os << "The int is " << t.a << endl; os << "The string is " << t.s << endl; return os; } }; int main(void) { test t1(); test t2(0, "Overloaded <<"); cout << t1 << endl; cout << t2 << endl; return 0; } Cliff Rhodes cliff.rhodes@juge.com crhodes@flash.net X CMPQwk 1.42 1692 X"If you would live innocently, seek solitude." - P --- Maximus/2 3.01 * Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00048 Date: 09/16/97 From: ROGER SCUDDER Time: 01:34pm \/To: DARRELL SALTER (Read 2 times) Subj: New to C Hi DARRELL, DARRELL SALTER was observed on 13-Sep-97, writing to ROGER SCUDDER Something about: New to C RS>> C and C++ are two distinct and different languages. If you want RS>> to learn C, you should post questions in the C echo. I know at RS>> first it will be confusing trying to understand what the RS>> differences are. In time it will become clear to you. DS> Ah.. ok. I thought an understanding of C was required before DS> tackling C++. Is that incorrect? It's not required. I have heard some different reasoning on this matter. Some feel that it is best to learn C first. C++ has many roots in C, but OTOH it also has roots in Object Oriented programming. Some feel that C teaches some difficult to break bad habits which will make learning C++ a bit more difficult. (For the record, these are not my opinions. These are things I have read here) Still others think that learning C after C++ it too hard and it is easier to learn C first. My opinion is that one must approach the study of another language with a open mind and with as little preconceived notions as possible (we're all human). So the decision wether to learn C or C++ first should be based on which one you want/need to learn first. My reasoning brings me to this: it is a good idea to gain some mastery of procedural programming idioms, ie; C, Pascal, COBOL, etc... before attempting to learning the more cerebral Object Oriented Programming idioms. Roger Scudder rogers@gim.net ... This message released to public domain. Use at your own risk. --- Terminate 5.00/Pro * TerMail/QWK * Terminate = Pointmailer+Tosser+Reader+Packer+QWK! --- WILDMAIL!/WC v4.12 * Origin: FIDONET * Remote Control BBS * 610-623-5273 * (1:273/420.0) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00049 Date: 09/16/97 From: DARIN MCBRIDE Time: 09:07am \/To: NEIL HELLER (Read 2 times) Subj: Why this construction? NH> I've been rolling C++ "enum"s around in my head and have come up with NH> a question. Given the following code snippet: NH> class button NH> { NH> public: NH> enum status (out, in); enum status {out, in}; // :-) NH> void set(status s) {state = s;} NH> status get() const {return state;} NH> private: NH> status state NH> }; NH> int main() NH> { NH> const button::status out = button::out; // #1 NH> const button::status in = button::in; // #2 NH> button panic; NH> panic.set(out); panic.set(button::out); panic.set(panic.out); // ? Can't recall... maybe this is object pascal... NH> [some other stuff] NH> } NH> Had the line NH> button panic; NH> been declared first in main(), could the verbiage in the line marked NH> #1 above have been written: NH> const panic.status out = button::out; ???? Nope. Its type is button::out. It might be able to be panic::out, but I can't recall right now. :-/ Try it! :-) NH> I _think_ the question can be rephrased as "why must enums be always NH> kept separate, apart from the objects to which they can apply?" I'm unsure of the question. Perhaps someone else will understand and answer, otherwise try rewording it. A list of my vocabulary... (Sorry, too many of those text-adventure games ) --- Maximus/2 3.01 * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00050 Date: 09/16/97 From: ANTHONY TIBBS Time: 05:59pm \/To: DARRELL SALTER (Read 2 times) Subj: Re: New to C RS> to learn C, you should post questions in the C echo. I know at RS> first it will be confusing trying to understand what the RS> differences are. In time it will become clear to you. DS> Ah.. ok. I thought an understanding of C was required DS> before tackling C++. Is that incorrect? Not necassarily. If your tutorial/course starts right from the basics, no. Otherwise, yes, a knowledge of C is a good idea. Sincerely, Anthony Tibbs ... Reality-ometer: [\........] Hmmph! Thought so... ___ Blue Wave/DOS v2.30 [NR] --- Maximus 3.01 * Origin: World of Power BBS * Private * Ottawa, ON (1:163/215.38) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00051 Date: 09/18/97 From: JOE DUNFORD Time: 07:06am \/To: DANIEL HEBBERD (Read 2 times) Subj: Joystick DH>How do i use a joystick through BIOS calls ? DH>a mouse for example is regs.x.dx and stuff ... DH>is there a joystick BIOS call ? You bet. Following code quoted from Tricks of the Game Programming Gurus, ISBN 0-672-30507-0. unsigned int Joystick_Bios (unsigned char stick) { //BIOS version of joystick read union _REGS inregs, outregs; inregs.h.ah=0x84; // This is joystick function 84h. inregs.x.dx=0x01; // This is read joystick sub func 1 _int86 (0x15,&inregs,&outregs); switch (stick) { case JOYSTICK_1_X: { return (outregs.x.ax); } break; case JOYSTICK_1_Y: { return (outregs.x.bx); } break; case JOYSTICK_2_X: return (outregs.x.cx); break; case JOYSTICK_2_Y: return (outregs.x.dx); break; default: break; } // end switch return; } I would prefer just to give you the info on the BIOS calls, but I don't have anything on me. This will have to do... ;) ___ SLMR 2.1a Lets make tapes of ourselves and sell them to whales. --- Maximus 3.01 * Origin: C+Net BBS. Programming & Networking. (1:342/1017) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: EDM00052 Date: 09/18/97 From: JOE DUNFORD Time: 06:53am \/To: JAMIE KOWINSKY (Read 2 times) Subj: Watcom C++ JK>I was reading though some of the messages posted here an I heard that JK>Watcom has a C++ compiler... I've never heard of thier compiler before JK>and have only ever used borlands comiler. Do you play computer games ? Most DOS games, upon a startup display a message like: DOS/4GW Protected Mode Run-time Version 1.97 Copyright (c) Rational Systems, Inc. 1990-1994 This indicates that the game was probably written in Watcom C/C++. JK>I need a good DOS based C++ compiler, borland gave up around version 3.0, JK>which is what I use for my dos development. Does Watcom perhaps offer a JK>C++ compiler for DOS? more developed that turbo C++ 3.0? Or did watcomm JK>sell out to gates as well? Watcom C/C++ is a multi-platform compiler. It will compile programs for: Windows 3.x/95/NT DOS 16-bit,32-bit (extended dos) AutoCAD ADS Novell Netware NLM OS/2 BTW I use version 10.6 of Watcom C to develop for 32-bit Dos & Windows DLL's. ___ SLMR 2.1a We all live in a yellow subroutine. --- Maximus 3.01 * Origin: C+Net BBS. Programming & Networking. (1:342/1017)