Can I call constructor explicitly, without using new, if I already have a memory for object?
new
class Object1{ char *str; public: Object1(c
You can use the following template
template inline void InitClass(T &t, Args... args) { t.~T(); new (&t) T(args...); }
usage:
struct A { A() {} A(int i) : a(i) {} int a; } my_value; InitClass(my_value); InitClass(my_value, 5);