Init Object array
#include <iostream>
using namespace std;
class CharClass {
char ch;
public:
CharClass(char c) {
ch = c;
}
char get_ch() {
return ch;
}
};
int main()
{
CharClass ob[10] = {
CharClass('a'),
CharClass('b'),
CharClass('c'),
CharClass('d'),
CharClass('e'),
CharClass('f'),
CharClass('g'),
CharClass('h'),
CharClass('i'),
CharClass('j')
};
int i;
for(i = 0; i <10; i++)
cout << ob[ i ].get_ch() << ' ';
cout << endl;
return 0;
}
Related examples in the same category