Pointers to increment object arrays

#include<iostream>
using namespace std;
class c1
{
int i;
public:
c1() {i=0;}
c1(int j) {i=j;}
int get_i() {return i;}
};
int main()
{
c1 ob[3] = {1,2,3};
c1 *p;
p=ob;
int i;
for(i=0;i<3;i++) { cout<<p->get_i()<<endl;
p++;
}
return 0;
}

Advertisements