andrew@resam.dk (Leif Andrew Rump) (06/24/91)
I've got my hands on Borland C++ (2.0) and I love it (not Borland, but C++ - well ok bc is also really nice :-) ). I've been reading some books to really get the spirit and I've stumpled into some things that I don't like and I also have some questions: In "The C++ Programming Language" by Bjarne Stroustrup (December 1986, it's not the updated C++ version (2.0 or 2.1)) he states on page 87: a*(b/c) could well be calculated as (a*b)/c Is this (still) the case? I tried the following: int a = 16000; int b = 10; int c = 5; on bc a*(b/c) worked as expected and gave 32000 and (a*b)/c gave (0x27100 / 5 -> 0x7100 / 5): 5785 i.e. overflow loss. I was a bit surprised when this didn't compile: for (int i = 0; i < 10; i++) ... for (int i = 0; i < 10; i++) Instead it is: for (int i = 0; i < 10; i++) ... for (i = 0; i < 10; i++) hmmm! I know that i is not in a "block" but ... On page 131 he states: Here are some plausible macros: #define Case break; case #define nl << "\n" #define forever for (;;) ... Here are some completely unnecessary macros: #define PI 3.141593 #define BEGIN { #define END } Should BEGIN & END be enumerated types or what is wrong with them? (NOTE: I don't use them even though I'm a Turbo Pascal programmer, but I do something similar as described below). I've brought the following from TP5.5 (and define it in andrew.h): #define constructor #define destructor ~ This way I can write a class like this: class object { name_t name; public : constructor object(name_t name) { object::name = new char[strlen(name) + 1]; strcpy(object::name, name); } ... destructor object(void) { delete name; } } Does all C++-compilers allow the ~ to be separated from the class name, like: ~ object(void) as it is expanded above. Also I overloaded: hex, oct & dec with hex(int, len = 0), ... like the old iostream. Why was they removed. Any comments? Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark UUCP: andrew@ambra.dk, phone: +45 39 27 11 77 / Currently at Scandinavian Airline Systems =======/ UUCP: andrew@resam.dk, phone: +45 32 32 51 54 \ SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark If it's broke, fix it (The MS-DOS way) If it aint broke, don't touch it (The Unix way) If we can't fix it, it ain't broke (Maintainer's Motto) If you can't fix it, fuck it (The U-boat way)