#include <iostream> using namespace std; class qwe { public: qwe() {} qwe(char * name, int a, int b):/*_name(strdup(name)),*/ _a(a), _b(b) { std::cout << " constructor(char,int,int)" << a << " " << b <<std::endl; } qwe& operator = ( const qwe& x ) { std::cout << " operator = " << std::endl; this->_a = x._a; // ... return *this; } private: char * _name; int _a; int _b; }; int main() { qwe * p = new qwe[10]; for (int i = 10; i--;p++) { char str[] = "hello"; new(p) qwe( str, 2, 3); } }
Standard input is empty
constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3 constructor(char,int,int)2 3