0% found this document useful (0 votes)
69 views

CVSC++: Cs-240 Data Structures Binghamton University Dick Steflik

C and C++ are similar programming languages but C++ introduces object-oriented programming features like classes, inheritance and polymorphism. Some key similarities between C and C++ include basic data types, compiler preprocessing, control structures and functions. Main differences are that C++ uses classes to encapsulate data and functions while C uses structs only for data, and C++ supports features like function overloading and operator overloading that are not present in C.

Uploaded by

vijay vidyalaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

CVSC++: Cs-240 Data Structures Binghamton University Dick Steflik

C and C++ are similar programming languages but C++ introduces object-oriented programming features like classes, inheritance and polymorphism. Some key similarities between C and C++ include basic data types, compiler preprocessing, control structures and functions. Main differences are that C++ uses classes to encapsulate data and functions while C uses structs only for data, and C++ supports features like function overloading and operator overloading that are not present in C.

Uploaded by

vijay vidyalaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 10

C vs C++

CS-240
Data Structures
Binghamton University
Dick Steflik
C++ was originally developed to be the
next version of C, not a new language.
Similarities

same built-in data types

same compiler preprocessor
– handles #include & #define
– conditional preprocessing #if, #ifndef and
#endef

same built-in operators on primitive
types (+-/*……)
Similarities (cont.)

Same built-in control structures
– if, for, while, switch ….

must have a function names “main” to
determine where the program starts

functions are defined the same way

programs can be split up into separate
files
Differences

in C all code exists in function and the
paradigm is that you manipulate data
with functions

in C++ classes are used to model the
behavior of data objects, behavior is
represented by functions and those
functions are used to modify the
object’s data
Differences (cont.)

in C a struct is used to make an
aggregate type and cannot have
associated functions

in C++ struct there may be associated
(part of the struct) functions to process
the data

in C I/O is accomplished via library
functions, in C++ it is done by using
object methods.
Differences

C++ has function overloading (two
functions may have the same name), in
C function names must be unique.

C++ has operator overloading
(operators can be redefined to do other
things)

C++ uses “nbew” and “delete” for
dynamic memory management, C uses
“malloc” and “free”
Simple C Program
# include <stdio.h>
int main(void) {
printf(“Hello World\n”);
return 0;
}
Software development in CS-240

various version of the GNU C++ Compiler
– cygwin – unix like environment is on all PODS windows machines
– Debian Linux – on all Linux Lab Machines
– KNOPPIX – a bootable CDROM version of Linux (bring a 700 Mb
CD to my office and I will burn a copy for you)
– coLinux – installs as an icon on your Wondows desktop, KDE
version of Debian (this is an easy way to get wireless internet for
Linux). I will help you do this if you want to try it. Doesn’t require
dual boot or a full Linux install
– available on your Sun accounts
– Eclipse w/c++ plugin and w/minGW – GUI IDE on Windows
– Eclipse w/C++ plugin - GUI IDE on Linux
Simple C++ Program
#include <iostream.h>
int main(void) {
cout << “Hello World\n”;
return 0;
}

You might also like