C++ (Qt)#include <QVector>#include <QtDebug> struct A{ A(){ qDebug() << "Constructed"; a_ = 0; } A(const A &other) { qDebug() << "Copied"; a_ = other.a_; } float a_;}; int main(){ QVector<A> vec; vec.reserve(3); vec.append(A()); qDebug() << sizeof(A); return 0;}
C++ (Qt)QVector3D vec[ 100 ]; // или QVector<QVector3D> vec( 100 );
C++ (Qt)#include <QVector>#include <QVector3D>#include <QtDebug>#include <QTime> int main(){ QTime time; time.start(); QVector<QVector3D> vec(9999999); qDebug() << time.elapsed(); return 0;}
C++ (Qt)struct vec{ float x; float y; float z;}; vec v;
C++ (Qt)float v[ 3 ];
QVector3D QVector3D::normalized() const{ // Need some extra precision if the length is very small. double len = double(xp) * double(xp) + double(yp) * double(yp) + double(zp) * double(zp); if (qFuzzyIsNull(len - 1.0f)) { return *this; } else if (!qFuzzyIsNull(len)) { double sqrtLen = sqrt(len); return QVector3D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen)); } else { return QVector3D(); }}