It depends on how your class looks but this would be a simple example:
#include <iostream>
using namespace std;
class MyClass {
int x;
public:
void setX(int i) { x = i; }
int getX() { return x; }
};
int main()
{
MyClass test[4];
int i;
for(i=0; i < 4; i++)
test[i].setX(i); `
for(i=0; i < 4; i++)
cout << "test[" << i << "].getX(): " << test[i].getX() << "\n";`
return 0;
}`
Testing it by calling X delivers:
test[0].getX(): 0
test[1].getX(): 1
test[2].getX(): 2
test[3].getX(): 3
4
solved Array of an object of a class [closed]