I wrote the following code:
#include
#include
#include
struct bar
{
std::string s3;
std::string s4;
}Ba
You can't use memcpy to copy objects or structure containing objects because they will not be properly initialized. Strings have pointers to char arrays, and if two strings can share the same pointer, there must be some kind of garbage collection (typically a reference counter). If you do f1.b1 = b2, the compiler will generate the code to initialize the strings correctly.