This is a straight forward solution which recursively traverse the tree in-order and keep the values in a vector.

Yet I'm not sure wether it has any draw back or does it even meet the O(h) requirement. It seems the vector keeps all the node value kind of exceed the O(h)?

```
class BSTIterator {
public:
BSTIterator(TreeNode *root) {
inOrder(root);
m_idx = 0;
}
void inOrder(TreeNode* root){
if(root == NULL)
return;
inOrder(root->left);
m_values.push_back(root->val);
inOrder(root->right);
}
/** @return whether we have a next smallest number */
bool hasNext() {
if(m_idx < m_values.size())
return true;
return false;
}
/** @return the next smallest number */
int next() {
return m_values[m_idx++];
}
private:
vector<int> m_values;
int m_idx;
};
```