Solved

Using FirstThat function with list containers

Posted on 1997-07-01
4
276 Views
Last Modified: 2006-11-17
Has anyone any example clue about using the FirstThat function with a list container such as TSListImp on Borland C++.
0
Comment
Question by:sagitarian
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
md041797 earned 70 total points
ID: 1164209
If memory serves:


int CondFunction (const obj &o, void *p) {
  o.testIt (p);
  }

int obj::testIt (void *p) {
  return *(int *)p == 5; // or whatever
  }

TSListImp <obj> list;
...
int testval = 4;
const obj &TheFirstItem = list.FirstThat (CondFunction, &testval);


0
 

Author Comment

by:sagitarian
ID: 1164210
Would just need an opinion on the global program construction.
Maybe, most of the time, the function 'CondFunction' is very specific to the function from which it is called.
Haven't seen yet a better way to arrange the program.
0
 
LVL 4

Expert Comment

by:md041797
ID: 1164211
Yes, that's the intent.  It allows the object to do it's own testing.
0
 

Author Comment

by:sagitarian
ID: 1164212
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 199
Starting a function in a c++ application with a TCP command from C# 4 76
Dialogbox API leak? 18 96
Path to  STL Map header file 1 58
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question