I came across with a statement with function call and as well as array index in the kind of code mentioned below .In this the statement s=o.init()[-1] is returning value of a1[0]. I am not cleared with the concept of how it is working, what this statement o.init()[-1] will do ?, i know 0.init() will give a call to function but what does [-1] specify? Pls help to solve this query?
#include<iostream>
using namespace std;
class a
{
char a1[1000];
public:
a()
{
a1[0]='a';
}
char* init()
{
cout<<"value of a1 is"<<a1<<endl;
return a1+1;
}
};
int main()
{
a o;
char s;
s=o.init()[-1];
cout<<"value of s is"<<s<<endl;
}