473,795 Members | 2,882 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_th ing( TT t, int prior );
// end vendors_file.h

For starters, the names reflected in the enum and the function
do_a_special_th ing 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>::i terator 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_th ing
if ( do_a_special_th ing( 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_t hing' directly inside the constructor of FOO.

Thanks in advance

Jul 23 '05 #1
0 1382

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

Similar topics

9
4652
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
1647
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 UINT32; #define LLSB(x) ((x) & 0xff) #define LNLSB(x) (((x) >> 8) & 0xff) #define LNMSB(x) (((x) >> 16) & 0xff)
29
2254
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 unsigned char. Since char may be signed (and if so, the return value of getchar() would be outside its range), doesn't the commented line in the following code produce implementation-defined behaviour?
11
677
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 function inside main. The prototype for the Write function is highlighted below. #define TRUE 1 #define FALSE 0
52
3794
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 level machine. C stands for portability and platform and machine independent. If the C compiler and C standard library are written in C itself, is it possible that one "standard" C compiler plus library is enough? The standard implementation is...
20
6090
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, as we seem to lack only a single 'step' to have "full separation"... We have a first project, namespace Ninterface, that contains the interface definitions in class1_interface.cs, like this: namespace Ninterface { public interface IClass1{
0
1995
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 methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
1
2780
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 template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
173
13998
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 filetype to invoke the C compiler. Here's a link http://www.microsoft.com/express/download/#webInstall The download is 2.6 megs, which is near a reasonable size for a compiler, but then setup.exe wants to download 87 megs of dot net framework...
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10165
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.