Thread: Using c with c++?

  1. #1
    h ֆhr s Nor's Avatar
    Join Date
    Nov 2001

    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
    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
    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:

    My best code is written with the delete key.

  4. #4
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    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));
    catfish *dual = new catfish;

    What would you do about the first example?

Popular pages Recent additions subscribe to a feed