[Scribus] Bonus-work...

PFJ paulf.johnson
Fri May 2 14:12:07 CEST 2003


> > When I started working on changes for Scribus, I spent a good while
> > fixing code so that it was proper C++ rather than C in a C++ shell (a
> > great example of this is casting). Many don't realise how important
> > using C++ casting is.
> Hmm, I thought I know something about c++ and oo-programming. But it seems I'm 
> lacking an important part here - what is c++ casting?

C casts in C++ are not a good idea and the C++ compiler doesn't always
optimise them correctly as well (plus they cause problems). C++ casts
are reliable as you know what you're getting and more over, the compiler
gets the right. If you're using C++, always use C++ casts.

Instead of

int foo = 4;
float f = (float)foo * 3.1415;

you use

int foo = 4;
float f = static_cast<float>(foo) * 3.1415;

Okay, there is more to the casting argument than what I've said, but I
can't remember all of them - suffice to say, use the correct casting for
the language :-)

In a similar way, while it's okay to use m(c)alloc/free, new and delete
are far better when using C++



Open your mind to a time where a company does not have control
Open your mind to a choice of applications which you can control
Open your mind from the closed world of those who seek total power
Open your mind to the wonderful world of Open Source

More information about the scribus mailing list