Why is C++11 act different than C++ in reference to the for statements.
I was pretty excited when I read how they worked in my textbook and now I am left with questions. Why am I getting different addresses?
Code:
#include <iostream>
#include <array>
using namespace std;
void changePointer(int change[])
{
cout<<change<<endl;
}
int main(int argc, const char * argv[])
{
array <int, 5> drew={34,22,55,56,98};
for(int items : drew)
cout<<"The arrays is:"<<items<<endl;
for (int change : drew) {
cout<<"The address is:"<<&change<<endl; //c++11 is suppose to do the same as below
}
for (int i=0; i<5; i++) {
changePointer(&drew[i]); // this did what I thought it would
}
return 0;
}