#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    95
    Rep Power
    13

    win32 c VS win32 c++?


    I was told by a friend that if you choose to learn the windows api that you can choose to code it in c or c++. Is this true? which is a better idea if you know both of them about the same but would need to "brush up"?

    Thanks,
    Dan
    C:\DOS C:\DOS\RUN RUN\DOS\RUN
    http://www.dandland.com
  2. #2
  3. No Profile Picture
    Not there when you need me
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Oct 2001
    Location
    Berlin, Germany
    Posts
    1,430
    Rep Power
    14
    The Wintendo API is basically C-oriented. So, if you like, you can use that. If, however, you want to use C++, you'll have to use something to get the API's functionality in an OO way, e. g. via MFC or Qt.
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222
    Basically, everything you can do in C you can also do in C++. So you should be able to take a C program and recompile it in C++. In practice, there may be a few minor errors; e.g., when I first tried it I found that two macros were defined in my C compiler but not in my C++ compiler.

    Windows API programming (originally SDK, for "software development kit") is classically done in C. If you read Petzold's books you will find all the code to be in C.

    MFC and other frameworks are done in C++ in order to encapsulate the message loop and other details of SDK and to provide a set of base classes that you can extend. If you don't want to use a framework (which you are indicating is the case), then you could still do your SDK programming in C++ just for "better C" reasons and for creating and using your own classes for non-GUI purposes.

    So you could indeed use either C or C++. I would advise using C++ since it would be the upward migration path, it contains all the features of C anyway, and since restricting yourself to C would be over-restrictive for no good reason.
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    If you look at the MFC classes, quite a lot of them are actually very thin wrappers around the native C API functions. By comparison, Borland's older OWL and newer VCL class libraries are much more object oriented.

    Frankly, I learned the basics of Windoze programming from the Petzold book, and then went straight to Delphi, C++ Builder and Visual C++. Before programming in Delphi, I also dabbled with Borland C++'s OWL library a bit. The Petzold background helped quite a bit, when I was programming Visual C++. In fact, I actually ended up writing one project in native C, simply because it had to be as lean and mean as possible. I think it's useful to skim over it, just so that you know how things were done before MFC. That information could come in handy for you too.

    BTW, I was already a fairly decent C/C++ programmer, before I even did any Windoze programming, so that was at least one hurdle that I didn't have to jump over.
    Last edited by Scorpions4ever; May 21st, 2003 at 01:35 PM.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    95
    Rep Power
    13
    Thanks a lot for your help guys, appriciate it!!

    Dan
    C:\DOS C:\DOS\RUN RUN\DOS\RUN
    http://www.dandland.com

IMN logo majestic logo threadwatch logo seochat tools logo