Exercise 3.34
p1 plus the distance from p2 to p1, it is illegal when p2 is the pointer after the tail
Exercise 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;
}
Exercise 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;
}