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
is
BP> impossible. :)
Well classes with member functions aren't as fast to access as their
counterparts in C with only data members. And C++ struct and class are
synonyms. In C a struct can't have functions :)
SS> void foo( int& HeyIMagicallyAlterYourVariableWithoutTellingYou )
DM> It can be avoided.
BP> Yes it can. But one who want to avoit it should better stay in C.
Well I commit the "sin" of mixing. I use C syntax with C++ functions and
Classes.
DM> char *i;
DM> i = (char *) malloc (30 * sizeof (char));
BP> Is that C++? What about
BP> char * i = new char[30]; // Are you payed a cent per character? :->
Thats the C++ version. But as I already said I commit the sin of mixing soo
often :)
BP> Actually in C you can do all the old C casts but also
BP> have other options. One is similar to old cast, just another syntax:
Well good. I'm not that great at C++ yet soo...
BP> long l = long(myInt); // really looks like conversion function
Indeed it does.
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.
No I have never casted away constness.. but heres the classic example:
printf ((char *) M_BINK_BANNER);
I think that was the line. Its from the Dragon Binky source. (My own pet
version of binkleyterm) M_BINK_BANNER was a #define of an int :( the proper
line is:
printf (MSG_TXT (M_BINK_BANNER));
ANd it works.
--- Maximus 3.01
---------------
* Origin: The Dragons Cave -- 2am - 5am CST (1:140/237.2)
|