473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Implementation dilema

Puzzled about an implementation here. In a vendor file, I'm faced:

// vendors_file.h
#ifdef __cplusplus
typedef void (*VOIDFUNCPTR) (...); /* pfunction returning
void */
#else
typedef void (*VOIDFUNCPTR) (); /* pfunction
returning void */
#endif /* __cplusplus */

enum TT {
jdx,
kdx
};

bool do_a_special_thing( TT t, int prior );
// end vendors_file.h

For starters, the names reflected in the enum and the function
do_a_special_thing aren't the actual names nonetheless, for test code
I've got:

// my_file.cpp
# include <iostream>
# include <list>
# include <vector>
# include "vendors_file.h"

using namespace std;

struct MYSTRUCT {
TT m;
int prior;
};

class FOO {
static void test_funct(...) {}
static void test_funct2(...) {}

std::map< TT, VOIDFUNCPTR> myMap;
MYSTRUCT my;

public:
FOO( list<MYSTRUCT>& lst) :
my(MYSTRUCT())
{
for (size_t idx(0); idx < lst.size(); ++idx)
{
//if ( test_funct3(lst[0]) )
//{
//}
}

myMap[jdx] = test_funct;
my.m = jdx;

if ( myMap.find(my.m) == myMap.end())
{
cout << " NOT FOUND " << endl;
}
else {
cout << " FOUND " << endl;
}

map<TT, VOIDFUNCPTR>::iterator it = myMap.begin();
for (; it != myMap.end(); ++it)
{
if ((*it).first == jdx) {
cout << " OK " << endl;
}
}
}

bool test_funct3( MYSTRUCT& tStruct)
{
// call vendor function do_a_special_thing
if ( do_a_special_thing( tStruct.m, tStruct.prior))
{
}
}
};

Here's my dilema: The constructor of FOO takes a list of 'MYSTRUCT'
as a passed parameter. Trouble is, I need to call the test_funct3
member function (see commented out code in constructor) for each
'MYSTRUCT' element in the list. Trouble is, there's no way for me to
do that with a list or any container type that I could think of. How
could I achieve my objective while maintiaining test_func3?

One approach would be to iterate throught the 'list' of items and call
'do_a_special_thing' directly inside the constructor of FOO.

Thanks in advance

Jul 23 '05 #1
0 1359

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
4
by: ma740988 | last post by:
The member variable addr2 -below- is the address received from a _vendor_ function (not shown). For discussion purposes lets assume the address is 0xCFF44000 The code: typedef unsigned int...
29
by: Enrico `Trippo' Porreca | last post by:
Both K&R book and Steve Summit's tutorial define a getline() function correctly testing the return value of getchar() against EOF. I know that getchar() returns EOF or the character value cast to...
11
by: ma740988 | last post by:
How would I modify the TEST_CMD function to essentially return the appropriate status? Simply put. TEST_CMD could return either status1 or status2. The return value will be passed to the Write...
52
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low...
20
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this,...
0
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template...
1
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of...
173
by: Ron Ford | last post by:
I'm looking for a freeware c99 compiler for windows. I had intended to use MS's Visual C++ Express and use its C capability. In the past with my MS products, I've simply needed to make .c the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.