C vs C++ What's the difference?

I can Google the answer but I want to know what you guys think: what are the practical difference between c and c++? Is one better than the other in certain situations? Pls no bully.

Attached: IMG_20181230_235020.jpg (495x594, 39K)

Other urls found in this thread:

amazon.com/Programming-Principles-Practice-Using-C/dp/0321543726
twitter.com/NSFWRedditVideo

they are two completely different programming languages.

They are completely different, c++ just happens to have a keyword that tells the compiler to read in and compile c.

They are completely different.
Think of it this way: humans have a part of our brain common with lizards and shit.
We still use that part of our brain on a daily basis, but we also have parts of the brain that are specific to humans.

That's the difference between C and C++. In modern C++ the only part that is in common with C is the syntax, but you would use a different standard library, and different ways of structuring your code.

But C++ still supports C, just like you can still communicate with a lizard by stomping your foot on the ground (hostile) or giving it some food (friendly).

C++ is better C. It's in the name. If you were thinking about using C don't and just use C++ pretty simple really.

Cool, thanks for the answer guys. I've been teaching myself c++, and always wondered what the difference was.

>tfw already started C
shit, what do now?

Attached: 1478931775300.jpg (800x900, 78K)

Base more of your life around what anonymous anime forum posters pull out of their asses.

Not a big deal the basic syntax is similar. Just read this if you're still a beginner amazon.com/Programming-Principles-Practice-Using-C/dp/0321543726

In the beginning, C++ was C but with OOP added. Now, they're basically entirely different languages. C is what Unix users program in, and C++ is what Windows users program in.

Prove me wrong. C++ is just plain better than C and can be used in the same situations. There's no reason to learn C now that C++ exist.

C++ is to C as lung cancer it to lung. Use C to be free from all the harmful elements of C++.

Get raped and kill yourself, you retarded fucking faggot sack of nigger shit with down syndrome.

Rude

Herr derr C is collg and good because it old and makes me feel like a 733t code. C++ is bad because someone who programmed hello world in C said OOP is bad. Fuck this board. And fuck "programming socks". I'm out.

Attached: 1555990034163.jpg (459x350, 23K)

Op here, there is no need to be nasty. You hurt my feeling a little bit, but I forgive you. I hope you feel better, user-kun

Knowing C will make you a better person.
C++ is for assholes.

I wrote C and Java almost exclusively in College. I did Java in industry for a few years and then recently entirely JavaScript and Python. I started studying C++ to know something that isn't a scripting language. It reminds me of C in many ways and more modern languages in others.

One feature I enjoy is the g++ compiler working reasonably well out of the box. There are less flags needed than in C. It comes preinstalled on osX. I'd imagine a lot of C like flags and makefile behavior exists but it's simpler overall.

Header and include files are also somewhat different, more streamlined.

Strcmp, strchr and co are not canon any more. There is a string class in the standard library with append methods and everything.

Malloc and Free seem to be no longer necessary. Stricts can be instantiated without meticulous memory allocation which is nice.

Java like features such as classes, static classes, private and public functions, and for each loops are all there.

It does feel like C but some of the error prone parts streamlined

C++ is a language with object-oriented elements where the leading design philosophy is something called "generic programming" that involves programming with templates. It was called C++ because the developer was previously a C programmer but found C was very limiting for large software development with smaller teams, but other languages were too slow. So he created a new language that was "fast like C" but had things useful for doing large software development with smaller teams, like classes to organize data and functions together. C and C++ are very different languages now that suffer the misfortune of being named similarly. They sometimes have similar syntax, along with Java and C#.

C is useful for certain niche applications, largely "I want to write an API that will be accessible wherever this virtual machine and model of computation is accessible and then build things on top of that in a more productive language."

C: no jobs.
C++: limited jobs.

I've using C for about 1.5 years now and have started learning C++ a little while ago
C is makes sense while C++ is just C with a bunch of retarded overthought features and it's recommended to use any C++ feature that has a C equivalent because their's is "better"

See you on monday.

C has far more jobs than C++

C++ is mostly a superset of C with a few differences but in practice you wouldn't program in C++ the way you would in C. C++ has
>function overloading
In C++, you can have two functions with the same name, like int f(int a) and int f(int a, int b). The compiler automatically deduces which one to call based on the number and types of the arguments you passed.
>references
A reference is like a pointer in that it points to some place in memory, except you don't need to use the * operator to dereference it, you can use it the same way you would use a normal variable, and you cannot change what object a reference refers to once it's initialized. This also means there is no reference equivalent of a null pointer. References are often used as funciton parameters to avoid copying or to allow modification of the passed object.
>classes
They are like structs in C except they also have member functions that operate on instances of the class, so you can do something like myvector.push_back(5) to insert a variable into a vector instead of using some external function like push_back(&myvector, 5) the way you'd do it in C.
>data hiding
Classes can have private members which can only be accessed by member functions and friends (a function or class that is declared as a friend of a class). Something like this obviously wouldn't make sense in C because C structs don't have member functions so private variables would just be inaccessible. The goal here is to prevent the user from modifying the state of an object in retarded ways, for example, by setting the length of a vector to a billion without actually changing the underlying storage.
>inheritance
If you have a base class like Vehicle, you can derive classes like Car and Bike from it that inherit its member functions and data members.

>polymorphism
This is related to inheritance. If you have a pointer of the type of the base class (Animal *) which points to an object of one of the derived classes (Dog) and you call one of its virtual member functions, the version defined inside the derived class (Dog) gets called instead of the one inside the base class (Animal).
Animal *p1 = new Dog; // pointer to Animal, base class of Dog
Animal *p2 = new Cat;
p1->makeSound(); // prints "woof"
p2->makeSound(); // prints "meow"

Polymorphism only works with virtual functions, if a class has no virtual functions then it's not polymorphic.
>function templates
You can write something like
template T add(T a, T b) {
return a + b;
}
// ...
std::string str3 = add(str1, str2);
int a = add(2, 3);

You can call this function using any type that supports the + operator, like integers, std::strings, and so on.
>class templates
An example of a class template is std::vector. You can have an std::vector, an std::vector, etc. The point is that you can define a template once and instantiate it for any type.
>operator overloading
You can define what an operator like +, [], etc. does when used on an instance of a class, so you can make your own container template and use [] to access its elements:
MyContainer container;
container.push_back(19);
int b = 5 + container[0]; // b = 5 + first element of container (19)

You couldn't do something like this in a language without operator overloading, like Java.

>new/delete instead of malloc
In C++, you use new and delete instead of malloc and free to do dynamic memory management (there is no equivalent of realloc or calloc). You can use malloc but it's generally not a good idea because new calls the constructor of the object you're allocating while malloc does not.
This also relates to classes. An instance of a class like std::vector manages memory dynamically yet you don't have to manually call delete to release the memory once you're done using your vector, because it is done by its destructor automatically.
>smart pointers
Smart pointers do memory management for you so you don't have to worry about delete.