Init class array: char type
#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] = { 'a', 'b', 'c','d', 'e', 'f',
'g', 'h', 'i', 'j' };
int i;
for(i = 0; i <10; i++)
cout << ob[ i ].get_ch() << ' ';
cout << endl;
return 0;
}
Related examples in the same category