ch_stack
constructors:
ch_stack data; //creates s[100] ch_stack d[N]; //creates N 100 element ch_stacks ch_stack w(4, "ABCD"); //w.s[0]='A'...w.s[3]='D'If we include each of these constructors in the
ch_stack class
definition, which one is invoked depends on the calling statement.ch_stack data;
s[100]
.
ch_stack d[N];
[n]
is not a function argument. As a subscript, [N]
defines d
as an array. Thus, you create an array of "N
" ch_stack
objects, each initialized by the default to s[100]
.
ch_stack w(4, "ABCD");
w.s[0] = 'A'
and w.s[3] = 'D'
.