C语言中, 数组定义时如果没有赋值, 之后是不可以使用=赋值的,需要逐一成员赋值或者用memcpy函数。
但是在C++中结构体中的数组可以(无需重载=运算符),需要区分以下3种情况:
#include<iostream>
#include<string>
using namespace std;
struct A
{
char a[10];
};
struct B
{
char *b;
};
struct C
{
string c;
};
int main()
{
A a1 ;
strcpy(a1.a ,"aaa");
A a2 ;
a2=a1; //深拷贝without defining the = operator
printf(&