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:

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

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -