Question

Is C/C++ one language or two languages? I heard C++ was just C with classes. Is that right?

Was it helpful?

Solution

C++ diverged from C in 1982-1983, and that's a long time in computer years. But, there are many C libraries with C++ compatibility, including the C standard library itself, and a steady stream of programs are ported across from C to C++. Many C programmers only know or use the features that are compatible with C++.

They are defined by different ISO standards from separate committees. Even when they define compatible features, it is often defined in different terms.

Referring to C/C++ is about as valid as referring to Italian/Spanish. You should be careful to whom and when you use such a term. But it's true that there is diffusion of ideas in both directions, and the similarities are more than coincidence.

OTHER TIPS

"C/C++" is precisely zero languages. It does not exist.

On the other hand, C is a language.

C++ is another language, which is kind of like C but also has classes and lots of other differences.


To be clear, @Zoidberg was spot on:

C and C++ are two completely different languages. C with Classes was the predecessor of C++, but the term is still often used for non-modern C++ (e.g. that uses raw pointers all over the place).

It is two languages. Calling C++ "C with classes" is like calling an elephant a four legged animal. It seems true till you compare it to a mouse.

There are many languages which derive from C: C++, Java, C#, JavaScript, csh, the list goes on. They are all different in many ways but they share similar syntax.

Of course C derived from B. But that is another story (and no one cares about B anymore.)

Simple answer: two languages

They are two different languages, although almost any C code is valid (not necessarily good) C++ code.

C++ was at first thought about as "C, but with classes", but as the time passed, it differed more and more and now C code is very bad C++ code. You can learn C or C++ or both, but you usually don't mix them up (but you can).

C/C++ is two languages. C is one language, and C++ is the other. C++ is considered a 'better' C. C is procedural, whereas C++ is object oriented. C++ has a lot of improvements over C, and has a similar syntax to C.

They are two different languages. C++ is so named because part of it is rooted from C and compatible with C in some sense.

According to Scott Myers's Effective C++, we can view C++ as a unified language with the following 4 components:

  1. C language part, blocks, statements, preprocessor, etc
  2. Objected Oriented C++: including class, encapsulation, inheritance, polymorphism, etc
  3. Template C++: including C++ templates, metaprogramming stuff
  4. The STL.

So C++ is more powerful than C in some sense.

The name "C" refers to a family of related languages, some of which are formalized as international standards. These include K&R C, ANSI C, C99, and C11.

The name "C++" refers to a family of related languages, some of which are formalized as international standards. These include C++98, C++03, C++11, C++14, and the speculated C++17.

The term "C/C++" is used by many people to informally refer to the intersection of C and C++, which has been intentionally maintained by the designers of C++.

C++'s immediate predecessor was in fact originally called "C with Classes". This is detailed in Bjarne Stroustrup's 1994 book "The Design and Evolution of C++" (and also here). The name was eventually changed to "C++", largely as a courtesy to the C community because it had become too tempting for people to shorten "C with Classes" to just "C" or "new C".

There are many language features in C++ that are not in C (the reverse is true to a lesser extent). In particular, the class-based model, due to its capability to invoke implicit function calls, is so powerful that C++ has (rather organically) evolved higher-level programming styles that make the typical usage of C++ much different than that of C. The most notable examples of this are associated with the concept called Resource Acquisition Is Initialization, which is embodied in the standard classes string, vector, and shared_ptr as well as the stream classes of the standard I/O library.

Other notes:

IMHO, I think the answer is that C/C++ are not one language, but two which are:

  • C Programming language
  • C++ Programming language

The C++ language is derived from the C language. C++ is the name for the C programming language with added 'classes' functionality. That means that the basic C language architecture has been enhanced to allow object oriented programming. It uses the "++" operator that means increment. C++ is an increment of C, which allows you to use procedural way or object oriented way or both of them in programming ways. C++ allows us to write code easier than C. But this does not mean that the C language is not suitable now, because we have C++. Each language is used for goal the purpose of software that is needed by a programmer. That's why ANSI made C a standard.

Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top