I am not able to understand what is being returned from function in following code (pointer or value) .
#include<iostream>
using namespace std;
class safearay
{
int a[10];
public:
int& operator [](int n)
{
if(n<0 || n>5 )
{
cout<<"Exceeded bounds"<<endl;
}
return a[n];
}
};
int main()
{
safearay sa1;
for (int j=0;j<10;j++)
{
sa1[j]=j*j;
}
for (int j=0;j<10;j++)
{
int u=sa1[j];
cout<<u<<endl;
}
}
Please explain