The following code results in Segmentation fault
=========================
#include <iostream>
using namespace std;
class abc{
public:
int a;
int b;
int c;
abc() {
a = 0;
b = 0;
c = 0;
}
};
int main()
{
for (int i = 0; i < 10; i++)
{
abc a[i];
abc *pa = &a[i];
pa->a = 10*i;
pa->b = 10*i;
pa->c = 10*i;
cout << "pa->a[" << i << "]: " << pa->a << endl;
cout << "pa->b[" << i << "]: " << pa->b << endl;
cout << "pa->c[" << i << "]: " << pa->c << endl;
}
return 0;
}
=========================
I know I need to overload subscript operator?
1. I am not sure how to do that. can some one suggest a way?
2. Is there anything else missing, all I want to do is read data, and
later display it?