Link to home
Start Free TrialLog in
Avatar of millos
millos

asked on

Difference between C and C++

I am taking a C++ class in the spring.  My background is creating databases using MS Access.  This will be my first real programming course, my question is:  What is the difference between C and C++??

TIA

Alex
Avatar of captainkirk
captainkirk

Simply put, the differences are mainly that:

1) C++ is designed more for object oriented programming via the use of classes - classes are like structs except that they encapsulate functions as well as data and provide access security levels for both. You will create instances of classes and call member functions of those classes. You will also learn about inheritance - how classes gain the attributes of other classes by deriving from them; and about polymorphism - this is the capability to treat objects from multiple classes identically because they all share one or more interfaces in common - for esample, Class Shape is some abstract class that cannot know how to draw itself, but if you derive a class from it called "Circle", class Circle does, and so would another class derived from Shape called "Square", etc...

2) C++ is a much more strongly typed language - the compiler will flag attempts to make implicit assignments from one type to another as opposed to just making automatic conversions, for example.

That's just a plain and simple starter, but it might give you some idea of what to expect...
kirk,

There is no difference in the type checking between ANSI C and C++.
Yeah, you know, you may be right - it may not provide stronger type checking than straight C - maybe just too used to having to cast classes...

:)

ASKER CERTIFIED SOLUTION
Avatar of Anthem
Anthem

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
At the deepest level, they are essentially the same, but in OOP functions an invisible parameter is passed (the object being used at the moment).

In C, where you do this:

Speedup(Car1,55);

you would do this in C++:

Car1.Speedup(55);


Both pass two parameters to the function, but in C++ the parameter is invisible (the object passes itself as a parameter, so you don't have to do it manually).