练习3.34
p1加上p2到p1的距离,p2是尾后指针时非法
练习3.35
#include<iostream>
using namespace std;
int main()
{
int a[] = { 1,2,3 };
auto* p1 = a, * p2 = end(a);
while (p1 != p2)
*p1++ = 0;
}
练习3.36
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int a[3] = { 1,2,3 };
int b[3] = { 2,3,4 };
if (end(a) - begin(a) != sizeof(b)/sizeof(*b))
{
cout << "not equal";
return 0;
}
for(size_t i=0;i!=3;++i)
if (a[i] != b[i])
{
cout << "not equal";
return 0;
}
cout << "equal";
return 0;
}