5 Replies - 461 Views - Last Post: 07 October 2013 - 09:25 AM Rate Topic: -----

#1 streek405  Icon User is offline

  • D.I.C Addict

Reputation: 10
  • View blog
  • Posts: 547
  • Joined: 10-March 13

What's the difference between C and C++?

Posted 06 October 2013 - 11:49 PM

What's the difference between C and C++? So far from what I've heard is that they are two completely different languages: C being a low level language, while C++ is much like Java, but a bit more complicated. Is this true? Which of these two is more useful to know and why?

Thank you!
Is This A Good Question/Topic? 0
  • +

Replies To: What's the difference between C and C++?

#2 Michael26  Icon User is offline

  • DIC-head, major DIC-head
  • member icon

Reputation: 355
  • View blog
  • Posts: 1,524
  • Joined: 08-April 09

Re: What's the difference between C and C++?

Posted 07 October 2013 - 03:41 AM

Each of those language has its own purpose, there is no universal language for everything. You should try both, write some examples in C and C++ and see which suits you better.

C++, as the name suggests, is a super-set of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. C++ is, like you said, much like Java which means it is multi-paradigm, procedural and Object oriented.

C++ supports data hiding(Encapsulation) a specific feature of OOP, C doesn't.
C++ supports function overloading(Polymorphism) while C does not. Overloading means two functions having the same name in the same program.
In C++ you can use functions inside structures, structures cannot contain functions in C.
C++ uses reference variables this allows two variable names to point to the same memory location, you can't do that in C.
Was This Post Helpful? 1
  • +
  • -

#3 Adak  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,168
  • Joined: 01-April 11

Re: What's the difference between C and C++?

Posted 07 October 2013 - 03:52 AM

Although C++ is built on a C format, and can use a lot of it's functions, there are large differences between the two. C++ was meant to use OOP (Object Oriented Programming), where the emphasis is on developing classes or types, and working with the problem in a more abstract way.

If your program related to dogs for instance, this is handy. A Greyhound is a lot like a Saluki, is a lot like a Scottish Deerhound, or a Borzoi. You have a type or class of dogs here. Traits can be inherited if say, you were to cross a Greyhound with a Deerhound. And you can extend that to include traits from all the hundred plus breeds of dogs.

On the other hand, classes are almost useless in other programs - like Chess for instance. We've never been able to find a useful class description for board positions, that we couldn't get quicker in more basic style programming in C. Speed is critical in chess programming! Classes are not.

C++ is the more useful language, because graphic programming, amongst others, can readily be done with OOP. That means a lot of the new Windows programming, games, etc., will be done in C++, not C.

The problem with C++ is that it has now had everything including the kitchen sink thrown into it. It has more nooks and crannies, than you can imagine. Be patient while you're learning it - very patient indeed.
Was This Post Helpful? 0
  • +
  • -

#4 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5826
  • View blog
  • Posts: 12,678
  • Joined: 16-October 07

Re: What's the difference between C and C++?

Posted 07 October 2013 - 04:33 AM

View PostAdak, on 07 October 2013 - 06:52 AM, said:

C++ is the more useful language


I would debate this, but this could relate to your kitchen sink observation. Yes, C++ has more abstraction, more tools, more... stuff.

C++ is not like Java. C++ is not like C. C++ is it's very own language. It is, perhaps, the most complex programming language in popular use. C++ advocates see this as multiparadigm flexibility, others see it as confusing. Actually, every advantage of C++ might be seen by others as a disadvantage.

One reason to use C++ is because it's a super set of the very simple language, C. Because C is simple, it can do some things faster than most anything else. But that fast code can get rather messy. With C++ you can leverage C and hide the mess. In theory.
Was This Post Helpful? 2
  • +
  • -

#5 streek405  Icon User is offline

  • D.I.C Addict

Reputation: 10
  • View blog
  • Posts: 547
  • Joined: 10-March 13

Re: What's the difference between C and C++?

Posted 07 October 2013 - 09:06 AM

Ok, thanks, you guys.
Was This Post Helpful? 0
  • +
  • -

#6 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 659
  • View blog
  • Posts: 2,270
  • Joined: 31-December 10

Re: What's the difference between C and C++?

Posted 07 October 2013 - 09:25 AM

The creator of C++ would call it a "general purpose systems programming language". If think baavgai explained it fairly well.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1