????C++ ??????????????????class????????primitive types?????÷?????????array??????
????A a[100]??// A is class
????int b[100]??
???????a???????????????????????????????????array????????????????????????????
????A ??POD?????????????????
???????A???????????POD???μ????????????????http://www.cnblogs.com/ly8838/p/3929025.html ???????????A ????????д????????????κβ???????????????в??
??????????A a[3] ???? A a1?? a2??a3?? ??????????????????????????????????
????A ????????????????????destructor??????
?????????????????struct??
struct StackObject
{
int _a;
int _b;
StackObject(): _a(0)?? _b(1)
{
}
};
?????????????????
void TestArraySemantics()
{
StackObject sa[10]; //line 1??call vector constructor iterator
sa[0]._a= 1;
sa[9]._b = 10;
}
??????VC++2010????????????????line1???????????????????????????????“???????????vector constructor iterator??”:
????????????????£?
void Vector_constructor_iterator(
int array_size??
int array_element_size??
void (*Ctr)(void *addr)??
char *arrayStartAddress)
{
for(int i = 0; i < array_size; ++i)
{
void *objAddr = arrayStartAddress + i * array_element_size;
Ctr(objAddr);
}
}
???????????????? C ?????????? StackObject ???????????????????е??á?
????????????????????????A a[3]?? ??A a1??a2?? a3?? ?????巢????????仯?????????????????????????????????????????StackObject??????????????????????array?????array??“????”????????30%???????array????ü????????????????????????????