During an interview, I was asked whether I knew the difference between C and C++.
I was wondering why such question being asked?
closed as not constructive by Jarrod Roberson, Walter, Glenn Nelson, gnat, Yannis Rizos♦ Jun 15 '12 at 1:03
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.
If the questions was phrased like "Do you know the difference between C and C++?" and you were allowed to just respond with "Yes" then I could see your confusion, but if they were actually asking "What -are- the differences between C and C++?" and a more open-ended answer was expected, I can see it as a legitimate "avenue of inquiry" as they say.
For example, only having ever coded in C and never in C++, I would barely be able to answer beyond a vague "C++ supports object oriented coding?".
Some people have observed that there's a huge amount of programming job applicants who can't write code at all. So, yes, asking "obvious" questions makes perfect sense.
There's a whole bunch of them. There's an infinity of people who have idiot lecturers who teach C-strings and
Of course, if you're an employer, then saying that they're the same or even similar is a big warning light.
There are also a small percentage of people (such as myself) who learned C++ before they learned C.
I'm sure you know the differences, but if you are a student who has only had a C++ class, and not a C class the parts of C++ that are not C compatible will not be obvious.
Some of the more obvious differences I've learned (not an exhaustive list) () struct data types originally could not contain functions, and can't have private members, meaning it is very difficult to Enforce the validity rules of an abstract data type in C. () classes are not supported in C () passing by reference using the ampersand operator is specific to C++ () C doesn't support streams or templates (*) malloc and free are intended for use only in C and not in C++
Unfortunately, I think it is becoming more and more common.
I think that young programmers freshly out of technical school (or where they learn their skills from) simply do not learn older languages such as C, C++, Lisp, OCaml, etc. They simply come out as "c# programmers" or "java programmers", etc. And when they find a job, they do not challenge themselves with learning other languages.
Of course there are some that do, but from those I have worked with, there is a general tendency for the younger programmers to follow this pattern.
Disclaimer: Since I am talking about education, then there can of course be differences from country to country about what is being emphasized in the education.
Probably not literally, in that they think C++ and C are one and the same, but in terms of truly understanding and being able to use the different features of C++, yes.
The main cause is the binary nature of listing languages / tools on your resume/CV. Essentially, the standard seems to be that if you got "Hello World" to compile and run in a language, than it is OK to list it on your resume/CV.
As it happens, the C version of "Hello, World!" also compiles and runs in C++. So, absent any other information, all that seeing "C++" on a resume tells me is that this person knows enough C to get "Hello, World!" running, and knows that most C programs will compile in C++.
Given that, I'm going to need to probe that a little bit on the interview. I probably wouldn't do so by asking a "Yes/No" "Do you know the difference?" question, in short because it has an obvious "right" answer. I would probably ask the candidate which language she liked better, why, and if there were any advantages to the one she didn't pick.
Yes, its common. I have seen this situation, either myself, coworkers, or third party libraries code.
Myself, for example, sometimes work with other programming languages or programming frameworks, and have to link, or update, to either "pure c" or "c++" libraries.
I just had the problem of modifying some "Pure C" code. And using "new" & "delete" memory allocation functions, that are "c++". The rest of the code was not object oriented
The compiler was C++. Later, I sued another compiler, and discovered the error.
If some one ask, verbally, or in a written test, or web online test:
"Do you know the difference between C or C++"
And you answer "Yes" or "No".
They really mean:
"Do you know the difference between C or C++, if you do please tell me ?"
So, you have to answer:
"Yes. The difference its that C++ its Object Oriented, although, you may use Pure C, inside a C++ program, for backward compatibility."
Sometimes, they will not ask you "if you do please tell me", and they will assume that you don't know. Don't just answer "yes", or "no".
As a foreward, note that this answer is not meant to declare that there are no differences or that I profess to know the differences, or even that I know than "Hello World" in either C or C++. It is an answer to the question by framing the terms of reference, pointing out that plenty of people know the elementary differences (e.g. one has some
It depends what you mean by 'programmer' and what you mean by 'difference'.
I'm a 'programmer' (although I call myself a developer) and I'd struggle to give any real differences between C and C++. If pressed I'd probably say that C++ is a superset of C that has namespaces and inheritence; different ways of dealing with memory. I know enough to patch some bugs or make some changes in your existing program but I can't imagine writing anything more than a simple utility in C or C++. I know enough to get by, but I don't paint myself as "knowing" either of those languages.
Then there are millions of mediocre programmers who barely know the single language they work with every day.
The term 'difference' is ambigious. I've pointed out what I see as some differences above, but I know they aren't definitive and complete. Very few people are going to know every difference - a lot more people are going to be able to give some vague answers (as I have) about object orientation.
Twenty years ago? Yes.
Today? Not so much.
The reason for this is because the programming landscape has changed in a big way. Many of today's programs are web-based; even programs written for desktops may be written in a higher-level language than C or C++. As such, unless you're a programmer who writes OS code, you may not know much about either of the two languages.
An interviewer may ask this question in an interview to gauge how much you know about programming fundamentals; if you know the difference between C and C++, then you likely know what object-oriented programming is, you probably understand libraries and compilers, you understand memory functions, references, pointers....many things that have influenced the programming languages of today. I don't use C++ much (and I can't really say that I'm an excellent programmer in any language; wisdom will come with time) but I can say that my experience with C++ has definitely made me a better programmer.