combining C and C++

This is a discussion on combining C and C++ within the C Programming forums, part of the General Programming Boards category; Can someone show me a good example of combining C and C++ to write a program that would be easier ...

  1. #1
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357

    Question combining C and C++

    Can someone show me a good example of combining C and C++ to write a program that would be easier to write than if you were using any of the two languages alone?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: combining C and C++

    Originally posted by volk
    Can someone show me a good example of combining C and C++ to write a program that would be easier to write than if you were using any of the two languages alone?
    Well, considering the fact that C++ has all of the abilities of C, I don't see the point. (The opposite is supposedly true also, though it's harder to implement the features of C++ in C.)

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >>The opposite is supposedly true also

    How would you implement templates in C?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357

    Unhappy

    Sheesh, it sounds like C++ is superior C. Why am wasting my time learning C when I could be learning C++ (no wonder the tutorials on this site are for C++).

    Is it possible to at least combine C++ and Java or something?

  5. #5
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    C++ is a superset of C, you're not wasting your time learning C, it will give you a base when you'll start to learn C++. Most of the things your learned in C will help you in C++.

    And why you want to combine Java and C++? well, one is compiled the other is interpreted (some times compiled, using JIT), but I don't see why you need to combine them, and when you write combine, what you mean? write one program in those 2 languages together?

  6. #6
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357
    ...and when you write combine, what [do] you mean? write one program in those 2 languages together?
    Yes, that's what I mean by combine. I'm sure all the programming languages out there have there advantages and disadvantages, and I just thought the combination of multiple programming languages would be a great way to offset a programming language's disadvantages.

    Aren't there any programs at all that exemplify what I'm saying?

  7. #7
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    Well, writing in the same source code, like asm and c/c++ that you can use inline assembler with asm("//asm code here"); I never saw something like this with Java.

    But I saw a lot of app that were built with various programming languages, like the GUI of the program were made in Java, while the core and function were made in C/C++.

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >How would you implement templates in C?
    With great care. You could simulate the effect of templates with some creative preprocessing that I'm not in the mood to attempt right now. Maybe later.

    >Sheesh, it sounds like C++ is superior C.
    No, just different. No language is superior, they are all designed with different goals in mind and that effects the outcome as well as the application field.

    > I just thought the combination of multiple programming languages would be a great way to offset a programming language's disadvantages.
    Possibly, but it's more likely that the glue that holds the two languages together would add more complexity to the meta-language than either of the component languages alone would have. Of course it is possible and has been done before, but at the source code level it's generally a bad idea and hard to create as well as maintain.

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

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