Share useful concept in C++ OOP


  • 2
    R
       Just comment out the last two function means that you do not want to override it, so it uses parent class implementation.  
    
    int peek() {
        if(hasNext()){
            Iterator it(*this);
            return it.next();
        }
    }
    
    // hasNext() and next() should behave the same as in the Iterator interface.
    // Override them if needed.
    /*int next() {
        
    }
    
    bool hasNext() const {
        
    }*/
    

    };


Log in to reply
 

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