Hi, I'm trying to hold a map of ints,and function pointers in C++
map<int, (*functPtr)(int, int)something
I need to hold a list of callbacks. For some reason this syntax is
not working. Any ideas? 2 1574
Hi,
Hi, I'm trying to hold a map of ints,and function pointers in C++
map<int, (*functPtr)(int, int)something
I need to hold a list of callbacks. For some reason this syntax is
not working. Any ideas?
At least you are missing a return type. C hat int as default but C++ wants
it explicitly. In your case void I assume.
I prefer typedef'ing function pointers as it makes code using those pointer
types easier. You might try this:
typedef void (*funcPtr)(int, int);
std::map<int, funcPtrsomething;
--
SvenC
"SvenC" <Sv***@community.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi,
>Hi, I'm trying to hold a map of ints,and function pointers in C++
map<int, (*functPtr)(int, int)something
I need to hold a list of callbacks. For some reason this syntax is not working. Any ideas?
At least you are missing a return type. C hat int as default but C++ wants
it explicitly. In your case void I assume.
Also, the template needs a type only, no name.
So:
map<int, void (*)(int, int)something;
>
I prefer typedef'ing function pointers as it makes code using those
pointer types easier. You might try this:
typedef void (*funcPtr)(int, int);
std::map<int, funcPtrsomething;
--
SvenC
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sachin_mzn |
last post by:
Hi,
When we use find method over a STL map. which searching algorithm is
used internally. Is it a hash search?
Or map implementation internally decide depending on element.
-Sachin
|
by: mcassiani |
last post by:
Hi,
I need use map faster as possible (I store in the map data about open
network connections).
First a question, this code fragment is from "The C++ Programming........
|
by: Szabolcs Horvát |
last post by:
Consider the attached example program: an object of type 'A' is inserted
into a 'map<int, Am;'. Why does 'm;' call the copy constructor of
'A' twice in addition to a constructor call?
The...
|
by: brzozo2 |
last post by:
Hello, this program might look abit long, but it's pretty simple and
easy to follow. What it does is read from a file, outputs the contents
to screen, and then writes them to a different file. It...
|
by: newbie |
last post by:
Same thing g++ complains when using hash_map<>, but is happy with
map<--I understand hahs_map is not standardized, but since the
compiler didn't complain something like 'hash_map<not defined', I...
| |
by: jabbah |
last post by:
Actually I'm quite sure I've missed something trivial here, but I just can't find it.
Seemingly I cannot read from a const map&
I try
#include <iostream>
#include <map>
using namespace std;
|
by: jabbah |
last post by:
I have some data in a map and I want to sort it. Currently I have implemented it like this:
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
|
by: Mr. K.V.B.L. |
last post by:
I want to start a map with keys but an empty vector<string>. Not sure
what the syntax is here.
Something like:
map<string, vector<string MapVector;
MapVector.insert(make_pair("string1",...
|
by: Juha Nieminen |
last post by:
joseph cook wrote:
Not always. By default, yes, but you can specify other comparators, eg:
std::map<int, int, std::greaterreversedMap;
|
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,...
|
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...
| |
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...
|
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: 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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |