Thread: Using c with c++?

  1. #1
    ‡ †hë Ö†hÈr 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 fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    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,897
    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