TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DAN MCGREGOR
from: BALOG PAL
date: 1997-07-24 08:48:00
subject: Sunir ventures into C++

                              Hi, Dan McGregor!
On 22 Jul 97  06:35:12 you wrote to Balog Pal
 DM> and in some cases its not quite as good. (The
 DM> classes aren't as fast as C struct's)
 BP> Could you prove that? struct is a sysnonym to class, so I think you say
 BP> is impossible. :)
 DM> Well classes with member functions aren't as fast to access as their
 DM> counterparts in C with only data members.  And C++ struct and class
 DM> are synonyms.  In C a struct can't have functions :)
So please decide what you want to compare. Members of structs/classes are
accessed in the very same way (and as fast as) in both languages. And speed
of member functions can't be compared as they do not exist in C.
 BP> And the new restricted cast operators. they are ugly to
 BP> read and write, but can save you bugs. Have you ever casted away
 BP> constness unintentionally? Now this can be cought at compile time.
 DM> No I have never casted away constness.
That's easy for people never using tha const keyword. :->
 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 own
 DM> pet version of binkleyterm) M_BINK_BANNER was a #define of an int :(
Cool. :) Dut in that case you probably got a "nonportable pointer-conversion"
warning.
But what I talked about is different thing.  Let's think thah M_** was const
unsigned char *. And you want to cast it to char * to use with printf ot
similar func taking that type. (char *) cast is really common in those
situations, where it's really a bug. And It will go unnoticed as the compiler
turns off all warnings converting pointers with an explicit cast like that.
But if you use reinterpret_cast you will get an error message. That
will not allow you cast away cv-qualifyers, just modify the type.
Paul
... Dammit, Jim! I'm a doctor, not a Computer Repairman!
--- OS/2 Warp
---------------
* Origin: The FlintStones' Cave in BedRock (2:371/20)

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™.