What does it mean when we use a variable in C++ like a function with a default value as its parameter? -
this question has answer here:
- calling ctor braces 2 answers
- why should prefer use member initialization list? 7 answers
i reading c++ code line. encountered weird code line variable used function 0 parameter!
template <class t> class stack { t data[50]; int nelements; public: //this line variable used function! stack() : nelements(0){} void push(t elemen); t pop(); int tamanho(); int isempty(); }; so mean when have: the constructor : private variable (0){}
this code line weird me! thanks
in initializer_list of stacks constructor, class member nelements initialized value of 0 upon creation of each stack object.
the value 0 not have special meaning here, other setting initial number of elements stack 0 gets created , empty.
Comments
Post a Comment