- In the extension bar, click the AdBlock Plus icon
- Click the large blue toggle for this website
- Click refresh
- In the extension bar, click the AdBlock icon
- Under "Pause on this site" click "Always"
- In the extension bar, click on the Adguard icon
- Click on the large green toggle for this website
- In the extension bar, click on the Ad Remover icon
- Click "Disable on This Website"
- In the extension bar, click on the orange lion icon
- Click the toggle on the top right, shifting from "Up" to "Down"
- In the extension bar, click on the Ghostery icon
- Click the "Anti-Tracking" shield so it says "Off"
- Click the "Ad-Blocking" stop sign so it says "Off"
- Refresh the page
- In the extension bar, click on the uBlock Origin icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the uBlock icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the UltraBlock icon
- Check the "Disable UltraBlock" checkbox
- Please disable your Ad Blocker
- Disable any DNS blocking tools such as AdGuardDNS or NextDNS
- Disable any privacy or tracking protection extensions such as Firefox Enhanced Tracking Protection or DuckDuckGo Privacy.
If the prompt is still appearing, please disable any tools or services you are using that block internet ads (e.g. DNS Servers, tracking protection or privacy extensions).
Question
Andre S. Veteran
Hello,
I have learned that I can create a linked list of objects, like this:
list< MyClass* > = myList;
I also know that if it were a list of primitive types, such as a list<int>, I could remove a specific element by calling
remove(myList.begin(), myList.end(), 8);
which for instance would remove any element that is 8.
However let's say MyClass has an attribute name_. I have a list of objects of type MyClass, and I'd like to create a function that finds and removes the object that has that name.
Stub:
void remove(string &name) const
{
remove(myList.begin(), myList.end(), ???);
}
The thing is, if I supply the string &name as an argument to the remove algorithm, it will attempt to compare MyClass objects with strings, which doesn't make sense. What I'd like it to do is compare the name_ attribute of its MyClass objects with the string &name.
I thought of supplying a boolean function that would return element->name_ == name, but the function would need two arguments (list<MyClass*> element, string &name) and I don't think that would work.
As you see I'm stuck.
Link to comment
https://www.neowin.net/forum/topic/626558-c-stl-remove-specific-object-from-list/Share on other sites
10 answers to this question
Recommended Posts