D
Dave
#include <iostream>
#include <valarray>
using namespace std;
int main()
{
valarray<int> v(10);
v[4] = 42;
v[5] = 243;
int *p;
p = &v[4];
cout << *p << endl;
p = &v[5];
cout << *p << endl;
p = &v[6];
cout << *p << endl;
}
This outputs:
42
243
-842150451
Should not the last line of output be 0? If not, why not?
Thanks,
Dave
#include <valarray>
using namespace std;
int main()
{
valarray<int> v(10);
v[4] = 42;
v[5] = 243;
int *p;
p = &v[4];
cout << *p << endl;
p = &v[5];
cout << *p << endl;
p = &v[6];
cout << *p << endl;
}
This outputs:
42
243
-842150451
Should not the last line of output be 0? If not, why not?
Thanks,
Dave