During an interview, I was asked whether I knew the difference between C and C++.
I was wondering why such question being asked?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
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
delete, or out-of-date tutorials or bad books, who learn "C++" but actually C, who think the two are pretty close.
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
+ characters in its name) and very few people will know all or even most of the differences.
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.