4 ms·
that is not valid c. and in valid c++ (which this isn't) you would not need those two integer values.
by zabzonk 4y ago
that is not valid c. and in valid c++ (which this isn't) you would not need those two integer values.
- tsimionescu 4y agoThere are some minor syntax errors - I should have written `int *elems` instead of `int[] elems`, and I forgot to declare `int elem` instead. Apart from these nitpicks, it's completely valid C. As for C++, the <int> is missing on the std::vector, the elem variable is again not declared, and instead of x[...] it should have been x.elems[...]. Otherwise working valid C++. And yes, the `cap` is not really required, we could use x.elems.size() instead.