Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List operator&(const List& firstList, const List& secondList)
- {
- List resultList;
- List::Node* firstPtr = firstList.head_;
- List::Node* secondPtr = secondList.head_;
- while (firstPtr != nullptr)
- {
- while (secondPtr != nullptr)
- {
- if (firstPtr->value_ == secondPtr->value_)
- {
- resultList += firstPtr->value_;
- break;
- }
- secondPtr = secondPtr->next_;
- }
- firstPtr = firstPtr->next_;
- secondPtr = secondList.head_;
- }
- return resultList;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement