/* g++ -g test.cpp -o test */ #include <iostream> #include <string> #include <chrono> #include <time.h> class A { public: int a1; }; int func(int count, class A *a) { for ( int i = 0; i < count; i++){ a->a1 = i; a++; } return 0; }; int main() { class A aa[4]; func(4, (class A*)&aa); printf("%d %d %d %d\n", aa[0].a1,aa[1].a1,aa[2].a1,aa[3].a1); return 0; }