TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: BALOG PAL
from: DANIEL MCGREGOR
date: 1997-07-26 22:05:00
subject: Sunir ventures into C++

Hello Balog.
24 Jul 97 08:48, Balog Pal wrote to Dan McGregor:
DM>> Well classes with member functions aren't as fast to access as
DM>> their counterparts in C with only data members.  And C++ struct
DM>> and class are synonyms.  In C a struct can't have functions :)
BP> So please decide what you want to compare. Members of structs/classes
BP> are accessed in the very same way (and as fast as) in both languages.
BP> And speed of member functions can't be compared as they do not exist
BP> in C.
Allright.  Member functions are basically just pointers to a function.  IE:
drlines::getlines.  And I've noticed that the C++ version of my dragon Linez 
program isn't as fast, or as small as the C version.
DM>> No I have never casted away constness.
BP> That's easy for people never using tha const keyword. :->
I'll have to say thats true, I usually just do the #define method :)
DM>> but heres the classic example:
DM>> printf ((char *) M_BINK_BANNER);
DM>> I think that was the line.  Its from the Dragon Binky source. (My
DM>> own pet version of binkleyterm) M_BINK_BANNER was a #define of an
DM>> int :(
BP> Cool. :) Dut in that case you probably got a "nonportable
BP> pointer-conversion" warning.
Nope I didn't.  Probably because I had all warnings turned off... :(  Showed 
me what I knew :)
BP> But what I talked about is different thing.  Let's think thah M_** was
BP> const unsigned char *. And you want to cast it to char * to use with
BP> printf ot similar func taking that type. (char *) cast is really
BP> common in those situations, where it's really a bug. And It will go
BP> unnoticed as the compiler turns off all warnings converting pointers
BP> with an explicit cast like that.
That can't be good.  At least if you actually use the const keyword on 
variables :)
BP> But if you use reinterpret_cast you will get an error message.
BP> That will not allow you cast away cv-qualifyers, just modify the type.
Well, I'll have to get a new version of a C++ compiler.  Where could I get 
DJGPP?
Daniel
--- Whoop-T-Doo v1.00b (In development)
---------------
* Origin: The Dragons Cave - Sysop Point (1:140/237.2)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.