Fedora Linux Support Community & Resources Center
Old 5th March 2010, 10:16 PM
roelj Offline
Registered User
Join Date: Jun 2009
Location: Netherlands
Age: 26
Posts: 290
STL map and functions.

I am trying to make a map that takes a string and links it to a function.

so what I did:
map<string,int> Index;
But how can I add a function that returns an int?

I tried:
Index["quit"] = quit();
But that won't work.

Is it possible to link a string to a function with the STL map?
And if so, how?
Reply With Quote
Old 6th March 2010, 01:01 AM
dmyersturnbull Offline
Registered User
Join Date: Sep 2008
Location: California
Posts: 235
The syntax you are using is incorrect; your code simply assigns Index to the value quit() returns. This page details C++'s syntax for function pointers: http://www.cprogramming.com/tutorial...-pointers.html
Index["quit"] = &quit
Reply With Quote
Old 6th March 2010, 06:43 PM
roelj Offline
Registered User
Join Date: Jun 2009
Location: Netherlands
Age: 26
Posts: 290
Re: STL map and functions.

Thank you for your help.

You pushed me in the right direction. Although I'm not exactly sure how it works.
But that will come in time.

Reply With Quote

functions, map, stl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C programming - use of functions manutdateroma Programming & Packaging 3 20th April 2007 09:15 AM
using CLI app functions, outside of terminal: how to? jsabarese Using Fedora 4 29th August 2006 06:01 PM
Few questions all regarding FC5 functions. Fault EOL (End Of Life) Versions 7 7th August 2006 05:01 AM
Signal safe functions in FC3 Def Programming & Packaging 2 9th April 2006 07:20 PM

Current GMT-time: 09:02 (Tuesday, 22-08-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat