Fedora Linux Support Community & Resources Center
  #1  
Old 5th March 2010, 09:16 PM
roelj Offline
Registered User
 
Join Date: Jun 2009
Location: Netherlands
Age: 22
Posts: 289
linuxfedorafirefox
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:
Code:
map<string,int> Index;
But how can I add a function that returns an int?

I tried:
Code:
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
  #2  
Old 6th March 2010, 12:01 AM
dmyersturnbull Offline
Registered User
 
Join Date: Sep 2008
Location: California
Posts: 235
linuxfedoramozilla
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
Code:
Index["quit"] = &quit
Reply With Quote
  #3  
Old 6th March 2010, 05:43 PM
roelj Offline
Registered User
 
Join Date: Jun 2009
Location: Netherlands
Age: 22
Posts: 289
linuxfedorafirefox
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.

Thanks!
Reply With Quote
Reply

Tags
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: 13:19 (Sunday, 20-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

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