Thread: Tripple pointers

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    24

    Tripple pointers

    Can you help me to start with them I cant find any information about them

    the exactly thing i need its Array of pointers where the pointers are pointing a menu like this idea below.

    Pls just help me with the syntax ...

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Personally, what I might do is create a Menu struct. This struct would then have an array (or pointer to the first element of a dynamic array) of MenuCategory objects. Each MenuCategory object would then have an array (or pointer to the first element of a dynamic array) of MenuItem objects. It is each MenuItem object that will contain the string.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Ok but my boss gave this one for training and make me learn that triple pointers, so can you help me build that like the picture... I understand what I must do but my problem is the syntax ... can you help me with the syntax ...

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by westony
    Ok but my boss gave this one for training and make me learn that triple pointers
    Your boss wants you to be a Three Star Programmer?

    Quote Originally Posted by westony
    I understand what I must do but my problem is the syntax ... can you help me with the syntax ...
    Follow my previous suggestion first. Post your attempt. When it is clear that you are capable of doing things in a more sensible way, I'll help you pretend to be a three star programmer.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Ok help me how make that
    Code:
     *mainmenu[] = {"menu1", "menu2", "menu3"};
    how to target those menu1,2,3 to those m1p1, m1p2 ... the other is easy game Just do not know how to declare that triple .............

  6. #6
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Code:
    ***all;
    char *mainmenu[] = {"menu1", "menu2", "menu3", NULL};
    all[0] = mainmenu;
    help its shows me:

    Warning 1 : 'char ***' differs in levels of indirection from 'char **'
    for the last roll ...

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    74
    Don't forget to allocate memory first.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    It would be something like
    Code:
    char *mainmenu[] = {"menu1", "menu2", "menu3"};
    char *submenu[] = {"sub1", "sub2"};
    char **all[] = { mainmenu, submenu };
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Quote Originally Posted by laserlight View Post
    Your boss wants you to be a Three Star Programmer?
    lol!

  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    Quote Originally Posted by laserlight View Post
    Personally, what I might do is create a Menu struct. This struct would then have an array (or pointer to the first element of a dynamic array) of MenuCategory objects. Each MenuCategory object would then have an array (or pointer to the first element of a dynamic array) of MenuItem objects. It is each MenuItem object that will contain the string.
    Why so complicated? Why not just reuse the original Menu struct instead of defining a MenuCategory and MenuItem?

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by MWAAAHAAA
    Why so complicated? Why not just reuse the original Menu struct instead of defining a MenuCategory and MenuItem?
    You could, but that would allow an arbitrary number of menu levels, which may be contrary to what was described. (That said, a MenuItem abstraction may still be useful.)
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of struct with pointers and function pointers
    By sdsjohnny in forum C Programming
    Replies: 3
    Last Post: 07-02-2010, 05:19 AM
  2. Replies: 7
    Last Post: 05-19-2010, 02:12 AM
  3. pointers to arrays
    By rakeshkool27 in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 07:28 AM
  4. pointers to constants and constant pointers
    By homeyg in forum C++ Programming
    Replies: 1
    Last Post: 06-18-2005, 12:02 AM
  5. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM