#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
class A
{
public:
std::string s;
A()
{
s = "string";
new(this)A(*this);
}
};
int main()
{
A a;
std::cout<<a.s;
return 0;
}
Otrzymuję pusty ciąg na wyjściu. Co mówi standard C++ o takim zachowaniu?wywoływanie konstruktora kopii wewnątrz innego konstruktora
Auwgh, naprawdę potrzebuję teraz kawy. –
Mam "ciąg" na wyjściu z GCC 4.5 – CapelliC
jest to: 'new (this) A (* this);' wywołanie konstruktora kopii wewnątrz innego konstruktora? –