C and C++

This is a discussion on C and C++ within the C++ Programming forums, part of the General Programming Boards category; I recently purchased Petzold's definitive guide to Win32 API and in the 2nd sentence it says need to know C ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    66

    C and C++

    I recently purchased Petzold's definitive guide to Win32 API and in the 2nd sentence it says need to know C language but I use C++ so I was wondering what is the difference between C and C++. I know C++ is just and upgrade to C (C++ incrementing C haha whoever thought that up was a genuis). I was looking through the C board and all I noticed was some syntax differences.

    Ryan

  2. #2
    Unregistered
    Guest
    There are more than syntax differences, believe me. I don't know that I agree with that book about needing to know C. But seeing as it doesn't say in the FAQ board, I'll tell you that you'll learn a whole know thought process regarding programming, and it might be hard figuring out classes, inheiritance, objects, etc, but what you can know now, C++ is about packaging code to make it reusable.

  3. #3
    Banned maes's Avatar
    Join Date
    Aug 2001
    Posts
    744
    I don't know that I agree with that book about needing to know C.
    you do need C. You need arrays, pointers, structures, loops, etc...
    what you don't need is cout, cin, printf,.... you'll be using other functions. It is true that programming for windows is totally different then programming for the console or DOS (with the messages and stuff) But I wouldn't say you don't need C. And if you start using MFC it will be usefull if you know classes. But if you know C++, you'll probably know enough to start windows programming

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    66
    I know about classes inheritance pointers etc.. In C++ but one thing I don't understand is objects I have read like 3 differenct definitions of object one was the class is the code and the object is the executable. The second program in Petzold's book I understand quite a bit of it except the messages but the pointers and classes functions and stuff was pretty easy. Thanks for your input it was really appreciated. The one thing I need help on is this
    wc.hbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH);

    I understand the assigning to the member but what is (HBRUSH) I believe HBRUSH is a structure but I have never seen a structure acessed like that.

  5. #5
    Banned maes's Avatar
    Join Date
    Aug 2001
    Posts
    744
    GetStockObject returns a HGDIOBJ as value. And this isn't the right datatype for the background member(wc.hbrBackground). So you need to do a casting, and that is what (HBRUSH) does. It converts HGBIOBJ to HBRUSH

Popular pages Recent additions subscribe to a feed

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