A strange question, I know.

This is a discussion on A strange question, I know. within the C++ Programming forums, part of the General Programming Boards category; Yeah, I proposed maps and made an example of a working system in the thread I linked to....

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    Yeah, I proposed maps and made an example of a working system in the thread I linked to.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  2. #17
    uh oh
    Join Date
    Jan 2005
    Location
    Ontario, CA
    Posts
    66
    Actually since I am seeking technically a map between one definition to another (both of which are number based, even though they technically use different mathematical bases) I think a map would do just fine for what I need to accomplish.

    0x034 (e.g.) needs to be mapped to 15

    thus when the msg 0x034 comes in to my message handler, I access the appropriate function pointer via... ptrArray[15](parameters);

    Thanks for the advise Elysia, a great help as always

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    Well, you don't really need to re-map the number of message at all. Since all messages have unique numbers, you can just map them to a function pointer directly, if you wish and pass any argument you think may be useful.
    The map example I made in the other thread is just a basic map-to-pointer example. If you modify the function pointer typedef, you should be able to map whatever number you want into appropriate function pointer and function handler.
    It's open to modifications.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  4. #19
    uh oh
    Join Date
    Jan 2005
    Location
    Ontario, CA
    Posts
    66
    Perfect. I guess I was so wrapped up in my own concept idea, it didn't even occur to me to take my own defines out of the equation. Thanks again

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by cyreon View Post
    Perfect. I guess I was so wrapped up in my own concept idea, it didn't even occur to me to take my own defines out of the equation. Thanks again
    It is quite common to "get stuck in the idea". Sometimes it helps to explain a bigger picture to someone else, and the other person may come up with a better idea of how this can be done [which is why I often ask for "what's the big picture" in threads where someone is asking "How do I ..."].

    Generally discussing ideas for solutions help, of course.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    It's wonderful to explain the bigger picture to someone.

    "So I need to make the ball hop down the hall and therefore I need to ... need to ... what am I doing this nonsense for?"
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #22
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by CornedBee View Post
    It's wonderful to explain the bigger picture to someone.

    "So I need to make the ball hop down the hall and therefore I need to ... need to ... what am I doing this nonsense for?"
    Oh, yes, the number of times I've had that experience: Explain something clearly to someone else, and you immediately realize what you are doing wrong...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #23
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    The nice thing that it works even with non-programmers. I habitually explain my problems to my father, who can barely follow me. Still helps.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC
    By tvsinesperanto in forum C Programming
    Replies: 34
    Last Post: 03-11-2006, 11:13 AM
  3. Strange results using dnsapi and windns
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-13-2005, 10:21 AM
  4. Question type program for beginners
    By Kirdra in forum C++ Programming
    Replies: 7
    Last Post: 09-15-2002, 05:10 AM
  5. Party question
    By Barjor in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 03-18-2002, 02:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21