Thread: Applications For C++

  1. #1
    People Love Me
    Join Date
    Jan 2003
    Posts
    412

    Applications For C++

    I'm well aware of many of the goodies you can create in C++, from console apps, to Win32 programs, to OpenGL animations and games...But since I'm not exactly a Win32 wiz-kid, and I don't work with OpenGL too much...what kind of useful programs could I create?

    I mean, you've got your silly little Celsius-to-Farenheit converter programs, but then you also have cool-ass little console programs that read data off disks and can even perform some lower-level tasks and such.

    At any rate, reading through some code on a few sites made me realize that I suck terribly at applying C++ to useful things. Can anyone perhaps point me in the direction of any lovely links that might show me some clever ways to apply C++ and such?

    Oh, and....how are pointers to functions useful, too?

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by Krak
    I mean, you've got your silly little Celsius-to-Farenheit converter programs
    tell that to NASA and watch yourself walk out of an interview witout a job
    Quote Originally Posted by Krak
    but then you also have cool-ass little console programs that read data off disks
    look into the <fstream> header
    Quote Originally Posted by Krak
    can even perform some lower-level tasks and such.
    ask some of the old-timers - a good amount of them have created operating systems, but you'll need to know a little assembly
    Quote Originally Posted by Krak
    Oh, and....how are pointers to functions useful, too?
    you may want to get past this before you try understanding more complex code...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Wink Most of us just enjoy the programming...

    Hmmm...

    Well, the sad truth is that until you become a whiz-kid, you won't be able to do much useful. Sometimes you'll have a unique idea for something that's particularly interesting to you… something related to another hobby, etc. But, most of us just enjoy the programming, even though someone else has done it before… probably better! I'm a "do-it-yourselfer." I build stuff with wood, I build circuits, etc. I even work on my own car... sometimes.

    Most commercial programs are written by more than one programmer. Some projects are just too big. I’m pretty sure that there’s over 1000 man-years of programming time in MS Office!!! And, no programmer is expert in every area. So, one person might head-up the user interface, another the drivers, etc.

    On the other hand, lots of shareware programs are written by one-person. And, if your car has computers under the hood, there’s a good chance that each computer is running a “little” program written by one programmer.

    Oh, and....how are pointers to functions useful, too?
    Search the board... it's a common question. The most common use of pointers is to get-around the fact that a function can only return one variable. So if you want your function to affect more than one variable, you can use pointers. Most books will show a "swap" function (where the values of two variables are excanged) to introduce pointers. With C-style strings, you use a pointer to the string so your function can "get to" all the characters in the string. Actually, in C++ you can usually use a reference instead of a pointer.

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >> Oh, and....how are pointers to functions useful, too?
    I think he's talking about function pointers, dougdbug

    Function pointers are nice if you want to avoid a bunch of branching statements, i.e.:
    Code:
    //Very annoying:
    switch(state)
    {
    case INIT_STATE:
       doFunction1();
       break;
    case RUN_STATE_1:
       doFunction2();
       break;
    case RUN_STATE_2:
       doFunction3();
       break;
     //etc..
    }
    
    void doFunction1()
    {
       //do something
       state = RUN_STATE_1;
    }
    You can replace this with:
    Code:
    void (*stateFunction)(void);  //declared somewhere, modified by various functions
    stateFunction = &doFunction1;
    
    stateFunction();
    
    -----
    
    void doFunction1()
    {
       //do something
       stateFunction = &doFunction2;
    }
    In this example you'll improve efficiency too, because you'll have eliminated a branching statement. Of course I rarely do something like this, but it's something you can do. Another example is callback routines - you might want to specify, when something happens you want a certain function to be called. Well, you'd just set a function pointer to the function you want, and the function you specified would be called when that something happens. This is especially useful for applications like scripting engines:

    Code:
    typedef void (*funcPtr)();
    map<string, funcPtr> funcMap;
    funcMap["attack"] = &attack;
    funcMap["jump"] = &jump;
    
    ...
    
    string cmd;
    getline(cin, cmd);
    map<string, funcPtr>::iterator it = funcMap.find(cmd);
    if(it != funcMap.end())
      (it->second)();
    Something along those lines.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    About the function pointers: It tries to get around the fact that functions are not treated as first class objects in C++. I very ocassionally use them for callback functions, but I much prefer functors (function objects) to function pointers.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #6
    Registered User
    Join Date
    Nov 2004
    Location
    Pennsylvania
    Posts
    434
    Just a suggestion, if it interests you you can get into Encryption methods with console apps. (That's what i do and it interests me) so just find what you wanna do and do lots of research on the topic and learn as best you can!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Get Installed applications list and applications activity
    By arunarora in forum C++ Programming
    Replies: 5
    Last Post: 05-25-2009, 09:41 AM
  2. Commercial applications?
    By audinue in forum C++ Programming
    Replies: 10
    Last Post: 07-21-2008, 11:13 AM
  3. A question about windows programming
    By Hussain Hani in forum Windows Programming
    Replies: 16
    Last Post: 05-23-2007, 07:38 AM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM