Using c with c++?

This is a discussion on Using c with c++? within the C++ Programming forums, part of the General Programming Boards category; Just as the question states above, is there any problems which could arise when letting the two languages work deeply ...

  1. #1
    Nor
    Nor is offline
    h ֆhr s Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299

    Using c with c++?

    Just as the question states above, is there any problems which could arise when letting the two languages work deeply together?
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  2. #2
    Amo ftbol!
    Join Date
    Dec 2001
    Posts
    2,136
    If you compile all the C code as C++ code, there will be no problems.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    For the most part, C code will compile and run properly as C++, but there are a few exceptions where the results will be different or valid C code will cause a C++ constraint violation. Take a look here for more details:
    http://users.utu.fi/sisasa/oasis/cpp...c-and-cpp.html

    -Prelude
    My best code is written with the delete key.

  4. #4
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    What about using malloc to create a pointer to a class?

    Using new calls the classes constructor, while using malloc does not. Then, wouldn't you have to call the classes constructor manually if you use malloc?

    catfish *dual = malloc(sizeof(catfish));
    vs.
    catfish *dual = new catfish;

    What would you do about the first example?

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