Something wrong with C++ compiler?


  • 0
    Y
    Admin:
    
    The code below causes Compile Error without returning any message about the reason ... 
    The code actually returns the head (of course it is not algorithm correct) but any compiler should    
     understand it ... Could any one tell me why?
        class Solution {
        public:
            ListNode* plusOne(ListNode* head) {
        /*        ListNode* ans = new ListNode(1);
                if(!head)
                    return ans;
                int c = 0;
                dfs(head, c);
                if(c)
                    ans->next = head;
                else
                    ans = head;*/
                return head;
            }
        /*private:
            void dfs(ListNode* p, int &c){
                if(p->next == NULL)
                    p->val = p->val + 1;
                else{
                    dfs(p->next, c);
                    p->val = p->val + c;
                }
                c = p->val>=10?1:0;
                p->val = (p->val + 1)%10;
            } */
        };

  • 0
    Y

    Same here. Seems to be a bug.


  • 0
    S

    Yes, compile error without any message.


  • 0

    Problem fixed. Sorry for the introduced error.


Log in to reply
 

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