Syntax problem...

  • 1

    Why it can't complile when I write this in a helper function, which return type is vector<TreeNode *>:

    return vector<TreeNode *> (1, NULL);

    I can't understand this reminder:
    required from 'std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = int; _Tp = TreeNode*; _Alloc = std::allocator<TreeNode*>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<TreeNode*>]'

    I write this before in another problem and it compiles:

    vector<vector<int> > f(m, vector<int> (n, 0));

    I don't know what's difference between these two codes.

  • 1

    I also come across this problem today. If you replace NULL with nullptr, the oj will compile it without error.
    Since c++11 is becoming mainstream, why not give it a try.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.