--------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200038 Date: 03/27/98 From: DARIN MCBRIDE Time: 07:39pm \/To: SEBASTIAN NOZZI (Read 3 times) Subj: Exceptions SN> Que son exceptions? Que tienen que ver con C++? Para que sirven, como e SN> manejan? The sole languages of this echo are English and C++ (and related computer languages). Thankfully you provided a translation... SN> What are exceptions and what do they have to do with C++? What are they SN> used for? Exceptions are for "exceptional" returns. It is a way of saying something weird happened, and "allowing" you to return funky objects rather than the one you said you would return. The way that this is returned allows you to put all your error-catching/error-handling code in one area, rather than spread out over your entire program. I don't personally use this feature of C++, though. i.e., int ReadByteFromStream(istream& is) { if (!is) throw StreamNotOpen(is); // assume this class is defined elsewhere. // ... other problems crop up, throw something else for each return ret_val; } try { char c; while (EOF != (c = ReadByteFromStream(my_com_port))) { do_something(c); } } catch(StreamNotOpen& sno) { cerr << "Reading from non-open comport" << endl; // handle this } catch(DoSomethingException1& dse) { // handle do_something's exception #1 } catch(DoSomethingException2& dse) { // handle do_something's exception #2 } // .. etc. catch(...) { // handle unknown error here } The main code is very compact. I find that all the catches are somewhat counterproductive in this way, although in languages where exceptions are part of the language from the beginning, this can be much more efficient than the old C way of handling errors where they occur or manually passing them up the stack. Note that if do_something called another function that threw an exception, and didn't catch the exception itself in do_something, we could catch it up here, too, allowing yet more error handling code to be in only one place. Hope this helps, Darin McBride C_PLUSPLUS moderator --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200039 Date: 03/27/98 From: DARIN MCBRIDE Time: 07:51pm \/To: MATHIEU BOUCHARD (Read 3 times) Subj: Sorting linked list TF>> How do i (quick)sort linked lists? DM> Quick sort requires random access which lists don't have. MB> I don't know what your quicksort is, but mine doesn't require random MB> access. I would still use an array version instead of a list version MB> cause i'm lazy, however, i can write a linked list version that won't MB> be *that* slow (i mean, it won't be anymore than O(n log n)). MB> Write your quicksort algorithm and i'll see why it can't be applied to MB> lists... Quicksort, by definition, requires random access. Many methods, such as insertion sort, IIRC, can use bidirectional access (being able to move forward and backward one at a time) or even unidirectional access (although usually at the cost of increased stack space). Quicksort needs to be able to quickly find arbitrary nodes and swap them. And I think quicksort has O(log n) timing, unless I'm already forgetting the standard timings. :-) If I'm right, that's a major difference in speed between nlgn and lgn. --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200040 Date: 03/27/98 From: DARIN MCBRIDE Time: 07:59pm \/To: SEBASTIAN NOZZI (Read 3 times) Subj: Variable argument function with no fixed19:59:3803/27/98 SN> Is this possible? I mean, what if I don't need or want any fixed SN> argument. Such as in: SN> void Function(...); Nope. Probably better to pass in an array of arguments... --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200041 Date: 03/28/98 From: MICHAEL MCGAVIN Time: 01:07pm \/To: DARIN MCBRIDE (Read 3 times) Subj: passing by reference Hi Darin, Note to everyone: While I'm here I'd like to thank everyone who helped out with my query. All info has been read and appreciated. :-) (I don't want to clutter up the echo and I'd netmail everyone but my experience with inter-zone netmail is that it never seems to work the way I want it to. ) Darin McBride was saying something to Michael McGavin about "passing by reference": MM>> void afunction(int *var1) MM>> { MM>> *var1=546; MM>> } MM>> void main() MM>> { MM>> int k; MM>> afunction(&k); MM>> } DM> This isn't passing by reference, per se. It's passing a pointer to DM> an object. The difference is, as you say, "manual." Reference DM> passing in every language is an automatic thing handled by the DM> compiler. For example, many people coming from a pascal background DM> would recognize: Thanks for helping to clear this up. It's been a great help. :-) One thing that still holds my interest is how the compiler handles it automatically. Is the code generated for passing by reference going to work out the same as passing a pointer to an object and subsequently dereferencing that pointer? All the best. Mike. email: zog@sans.vuw.ac.nz --- GoldEd 2.50 UNREG * Origin: DARK SKIES Astronomy -- Wgtn, NZ. +64-4-235-6887 (3:771/1560.201) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200042 Date: 03/28/98 From: JABO Time: 02:49pm \/To: ALL (Read 3 times) Subj: loading a file hey everyone, i can init. graphics mode asm { xor ah, ah mov al, 0x13 int 0x10 } in Turbo C++ 3.0 now, how do i load a pcx file? in 320x200x256 ?? --- Maximus/2 3.01 * Origin: A Place Called Joe's (1:106/977) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200043 Date: 03/28/98 From: JABO Time: 02:52pm \/To: ALL (Read 3 times) Subj: heheeh ok its sad to say, but i dont have the internet How or where can i find the SNIPPETS packs? Thanks (to anyone who can help) --- Maximus/2 3.01 * Origin: A Place Called Joe's (1:106/977) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200044 Date: 03/27/98 From: AUKE REITSMA Time: 09:43pm \/To: JO GERAERTS (Read 3 times) Subj: convert char to int... Hi Jo, On 16 Mar 98, 17:35, you wrote to All JG> In a program I want to use a ini file. I've got a predefined JG> function that reads the value and stores it in a string (char JG> str[2]) But the value is a number is an I want to convert it to a JG> integer. How can I do that. I tried this: JG> int x=(int)str; JG> I also tried this: JG> int x=(int)*str These kinds of conversions must be done explicitly by a function. NOT by a cast. E.g.: int x = atoi( your_string_value ); BTW: your string array is probably too small. The array str[2] can hold only a single digit in addition to the terminating ascii nul character. BTW2: You may wish to read the C_echo in addition to C_plusplus. Greetings from _____ /_|__| Auke Reitsma, Delft, The Netherlands. / | \ -------------------------------------- --- GEcho 1.00 * Origin: Home by the C (Auke.Reitsma@net.hcc.nl) (2:281/400.20) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200045 Date: 03/28/98 From: KURT KUZBA Time: 11:34pm \/To: MARK HOOVER (Read 3 times) Subj: Need More Memory MH> Anybody have some XMS routines that would allow me to do MH> linked lists and stuff like that versus having to copy MH> everything element by element (character by character) MH> into XMS? I think you move things into XMS by 16K blocks, no? You would move your data to an allocated 16K section and just push it into XMS, I would think. memmove() would work fine for moving the data. > ] Well, I wasn't expecting the Spanish Inquisition!........... --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 203 C++ Ref: F4200046 Date: 03/27/98 From: MARIO SEMO Time: 10:33am \/To: JO GERAERTS (Read 3 times) Subj: convert char to int... Hallo Jo! Antwort auf eine Message von Jo Geraerts an All: JG> In a program I want to use a ini file. I've got a predefined function JG> that reads the value and stores it in a string (char str[2]) But the mh. a) what is a 'ini' file?? can;t find this in my ARM. b) assume an ini is a data storage. what format is the data stored? hex? as string? if hex: what is sizeof(string). on my 2 machines : one said 32, one said 64. if string : "1234" also needs more then 2 bytes. JG> value is a number is an I want to convert it to a integer. How can I JG> do that. I tried this: JG> int x=(int)str; this stores the address of str as int converted to x. JG> int x=(int)*str this converts the FIRST character (str[0]) to an int and stores it to x. if the data is hex: int x(*(int *)str); if the data is a string : int x(atoi(str)); Servus, Mario! --- FleetStreet 1.21 PR#2 * Origin: LC/32 Development Team, KirchnerSoft, Vienna, Austria 2:310/14.11)