C++ (Qt)QWidget * w;..QLineEdit * e = static_cast <QLineEdit *> (w);
C++ (Qt)QWidget * w;QLineEdit * e = static_cast <QLineEdit *> (w);if (e){ // OK}
C++ (Qt)double d;float f;,,,d = static_cast <double> (f);f = static_cast <float> (d);
QWidget * w;..QLineEdit * e = static_cast <QLineEdit *> (w);
d = static_cast <double> (f);f = static_cast <float> (d);
int i = 0x11223344;char c = static_cast<char>(i);
C++ (Qt)struct Matrix2x2 { double m00, m01, m10, m11;}; void Transform( const Matrix2x2 & m, float * ioX, float * ioY ){ double x = *ioX; double y = *ioX; *ioX = x * m.m00 + y * m.m10; *ioY = x * m.m10 + y * m.m11; }
C++ (Qt)d = static_cast<double>(f);
C++ (Qt)f = static_cast <float> (d);
C++ (Qt)struct Matrix2x2 { double m00, m01, m10, m11;}; void Transform( const Matrix2x2 & m, float * ioX, float * ioY ){ double x = *ioX; double y = *ioX; //IMHO: there's no difference in this situation whether I'll write explicit conversion in c++ style or in c-style //however i know few about c language, so I'd prefer to do everything in c++ way rather than in c-way *ioX = static_cast<float>(x * m.m00 + y * m.m10); //or in C-style (float)(x * m.m00 + y * m.m10) *ioY = static_cast<float>(x * m.m10 + y * m.m11); //or in C-style (float)(x * m.m00 + y * m.m10)}
class ControlUnit {... const QList<Terminal*>& terminals() { return terminals_; } const QList<const Terminal*>& terminals() const { return reinterpret_cast<const QList<const Terminal*>&>( const_cast<ControlUnit*>(this)->terminals()); }}