Solved

C/C++

I don't know how many questions I actually have on the subject, but I guess that we'll find out as I type this out. I have experience in C++, I did in Java but remember very little, and have dabbled in Python and Ruby. I like C++ and I have been looking at job postings at big companies to see just what I need to know. Most say experience in C/C++, so I was wondering if I should work my way up from C to C++, shouldn't be hard seeing how they have the same workings. Or should I just continue with C++ and then learn C later on? Also how much do you usually need to know before you can say that you know a programming language. I don't need any websites or book recommendations because I have books on both C and C++. So just post your comments, thanks.
12 answers Last reply Best Answer
More about tomshardware
  1. C is not a subset of C++ even though they share much syntax; it is enough different that you can treat it as a new language.
  2. I know that C isn't a subset of C++, but C++ is a addition to the C language correct? But should I try and implement everything I have learned in C++ over to C then continue in C, or should I just continue C++?
  3. No, C++ is not an addition to C. C++ object oriented code will not convert to C. Well, you CAN implement a form of objects in C, but it is not easy or pretty.
  4. So again my question, continue with C++ or learn C?
  5. Best answer
    C++ is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code (cause C++ is advanced), so C++ is a High-level language while C is Mid-level language.

    so continue with C++ since you have experience with it, after that you can learn C fast, you can see the differences here.
  6. Best answer selected by shattered space.
  7. RyQril said:
    C++ is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code (cause C++ is advanced), so C++ is a High-level language while C is Mid-level language.

    That is false, but I will not argue it here ;)

    Actually, you already proved it false: You say C++ is a super-set of C, but if that were true then ALL C code could be complied with a C++ compiler. However, you already stated that "C++ can run most of C code".
  8. i didn't prove any of it as false :S, C++ came form C so its a superset, as i mentioned C cant run "C++ code" not "compile" it with C++.
    The C++ began as enhancements to C, first adding classes, then virtual functions, operator overloading, multiple inheritance, templates, and exception handling among other features,
    so thats why C++ cant be compiled with C compiler.

    EDIT: it depends on the compiler, for an example DMC is a good C compiler that will compile C++ programs, and the GCC the C++ compiler contains C compiler too.
  9. If C++ were a superset of C then ervery valid C program would also be valid C++ (but not the other way round). This is not the case.
  10. ^ +1 That is what I tried to say, but not as clearly ;)
  11. RyQril said:
    i didn't prove any of it as false :S, C++ came form C so its a superset, as i mentioned C cant run "C++ code" not "compile" it with C++.
    The C++ began as enhancements to C, first adding classes, then virtual functions, operator overloading, multiple inheritance, templates, and exception handling among other features,
    so thats why C++ cant be compiled with C compiler.

    EDIT: it depends on the compiler, for an example DMC is a good C compiler that will compile C++ programs, and the GCC the C++ compiler contains C compiler too.


    Yes, C++ code cannot be compiled with a C compiler, but anything other than trivial C code cannot be compiled with a C++ compiler either. In other words, take some reasonably intense C code source files, rename their extensions from .c to .cc or .C, and try to compile them as C++; you may be surprised! C++ may have begun as an extension to C, but the two languages diverged down two separate paths years ago, never to meet again :D

    Also, to be pedantic, The GNU C compiler is gcc, and the GNU C++ compiler is g++, two separate compilers.
  12. GCC can actually refer to the C compiler or the entire collection of compilers in the GNU project. So in one sense GCC does contain a C and a C++ compiler ;)
Ask a new question

Read More

Programming C/C++ Apps