C++ (Qt)class CMain : public QObject{ Q_OBJECTpublic: CMain(QObject *parent=0) : QObject(parent) {} void test(){ if(!list.empty()) A *val = list[0]; } ~CMain() {} private: QVector<A *> list;};
class B : public QObject{ Q_OBJECTpublic: B(QObject *parent=0) : QObject(parent) {} B(const B &other) : val1(other.val1), val2(other.val2){} ~B() {} int val1; double val2;};
class B : public QObject{ Q_OBJECTpublic: B(QObject *parent=0) : QObject(parent) {} B(B&) {} ~B() {}}; class A{public: A() {} A(A&a) : val1(a.val1), val2(a.val2){} ~A() {} B val1; B val2;};class CMain : public QObject{ Q_OBJECTpublic: CMain(QObject *parent=0) : QObject(parent) {} void test(){ if(!list.empty()) A val = list[0]; } void append(A val){ list.append(val); } ~CMain() {} private: QVector<A> list;};
A(A&a) : val1(a.val1), val2(a.val2){}
C++ (Qt)class B : public QObject{ Q_OBJECTpublic: B(QObject *parent=0) : QObject(parent) {} explicit B(const B &b) {} ~B() {} inline B& operator = (const B &b) {return *this;}}; class A{public: A() {} A(const A& a) {val1 = a.val1; val2 = a.val2;} ~A() {} B val1; B val2;};class CMain : public QObject{ Q_OBJECTpublic: CMain(QObject *parent=0) : QObject(parent) {} void test(){ if(!list.empty()) A val = list[0]; } void append(A val){ list.append(val); } ~CMain() {} private: QVector<A> list;};
C++ (Qt)class B : public QObject{ Q_OBJECTpublic: B(QObject *parent=0) : QObject(parent) {} ~B() {} explicit B(const B &b) : QObject(b.parent()) {assign(b);} inline B& operator = (const B &b) {assign(b); return *this;} public: void assign (const B &b) {/* do something*/}};