don't understand "strange" constructor
I found this constructor in a C++ book. Unfortunatly the authors didn't think it's worth any explanation or I'm too blind to find it ;)
Code:
class iStack {
public:
iStack(int capacity): _stack(capacity), _top(0) {}
[...snip...]
private:
int _top;
vector<int> _stack;
}
I don't understand the blue part. What does it do? I would expect it to do nothing because there is nothing between { and } and there is no further implementation for the constructor, but _stack(capacity) looks like a possible constructor for the vector :confused:
Does it initialize _stack and _top ? If so, why not beween the { and } ? :confused: