c++ pp page61
c++ pp page76
不能將一個數組直接賦值給另一個數組,如
int cards[4] = {3,4,5,6}; int hands[4]; hands = cards; //not allowed
但是,可以使用賦值運算符(=)將結構體賦值給另一個同類型的結構體,即使成員是數組,如:
struct inflatable { char name[20]; float volumn; double price; }; int main() { inflatable bouquet = { "sunflowers", 0.20, 12.49 }; inflatable choice; choice = bouquet; //allowed, even though there is an array in struct }
一篇解釋如下: