Sign in with
Sign up | Sign in
Your question
Solved

C/C++

Last response: in Applications
Share
June 18, 2012 9:04:35 PM

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.

More about : question

a b L Programming
June 18, 2012 10:13:10 PM

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.
m
0
l
June 18, 2012 10:25:34 PM

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++?
m
0
l
Related resources
a b L Programming
June 18, 2012 10:33:20 PM

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.
m
0
l
June 18, 2012 10:42:52 PM

So again my question, continue with C++ or learn C?
m
0
l

Best solution

June 19, 2012 5:34:12 AM

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.
Share
June 19, 2012 3:24:30 PM

Best answer selected by shattered space.
m
0
l
a b L Programming
June 19, 2012 6:56:56 PM

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".
m
0
l
June 20, 2012 4:58:39 AM

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.
m
0
l
a b L Programming
June 20, 2012 6:03:49 AM

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.
m
0
l
a b L Programming
June 20, 2012 7:28:52 PM

^ +1 That is what I tried to say, but not as clearly ;) 
m
0
l
a b L Programming
June 20, 2012 7:44:17 PM

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.
m
0
l
a b L Programming
June 21, 2012 7:30:30 AM

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 ;) 
m
0
l
!