#include <iostream>
#include <vector>
#include <limits>
usingnamespace std;
struct Example
{
void Access()
{
cout << "Accessing a class" << endl;
}
};
int main()
{
int n = 0;
cout << "Enter n: ";
cin >> n;
cin.sync();
//allocating memory for an array of 'n' Examples
vector<Example> nExamples(n);
//accessing each of them
for(vector<Example>::iterator iter = nExamples.begin(); iter != nExamples.end(); ++iter)
{
iter->Access();
}
//or just one of them
nExamples[n - 1].Access();
cout << "Press ENTER to continue..." << std::endl;
cin.ignore( numeric_limits<streamsize>::max(), '\n' );
return 0;
}