2. contents
2
2.1 A Brief History of C & C++
2.2 C Vs C++
2.3 A Simple C++ Program
2.4 Application of C++
2.5 Structure & Class
2.6 Compiling & Linking
% - 3
By:-Gourav Kottawar
3. 2.1 A Brief History of C & C++
3
The C++ programming language
has a history going back to 1979,
when Bjarne Stroustrup was doing
work for his Ph.D. thesis
The Simula 67 language
"C with Classes“
C++
By:-Gourav Kottawar
4. 2.2 C Vs C++
4
C C++
Language
Type
Procedural Oriented Language
Multi paradigm language, includes STL,
generic programming, procedural
programming, functional programming,
metaprogramming Object Oriented
Programming
Platforms
Almost anything on the planet; requires
recompile
Any, but libraries used can make it limited
Developed
by
Dennis Ritchie & Bell Labs Bjarne Stroustrup
Influenced
awk, csh, C++, C#, Objective-C, BitC, D,
Concurrent C, Java, JavaScript, Limbo,
Perl, PHP
Ada 95, C#, Java, PHP, D, Aikido
Typing
Discipline
Static, Weak Static, Unsafe, Nominative
Paradigms
Imperative (procedural) systems
implementation language
Multi-paradigm, STL, generic programming,
procedural programming, functional
programming, metaprogrammingBy:-Gourav Kottawar
5. 5
C C++
Influenced
by
B (BCPL,CPL), ALGOL 68, Assembly C, Simula, Ada 83, ALGOL 68, CLU, ML
Designed
by
Dennis Ritchie Bjarne Stroustrup
Programmi
ng-String
type
Cannot use string type but declare it
as an array of characters
Can use std::string or design a string by user
Major
Implement
ations
GCC, MSVC, Borland C, Watcom C
GNU Compiler Collection, Microsoft Visual C++,
Borland C++ Builder
Speed
C applications are faster to compile
and execute than C++ applications
+-5% when compare with C if you know how to
make a good use of C++.The performance of C++
and C are equal, since compilers are mature(now
is 2012), if your C++ codes are much slower than
C, don't flame C++ but blame yourself.
By:-Gourav Kottawar
6. 6
OOP
(Object
Oriented
Programmi
ng)
Not built in; has the freedom to
setup structures to act like objects.
Lacking the ability to
encapsulate(annouced private) is a
big weakpoint
Yes-polymorphism and inheritance, Classes.
Appeared
in
1972 1985
Execution
Flow
Top to Bottom Bottom to Top
Garbage
Collection
Manual; allows better
management of memory.
Manual, you could manage the memory as C
did, or use smart pointer , destructor to provide
better and safer mechanism.According to your
implementation, smart pointer can be zero
runtime impact
Usual
filename
extensions
.c .cc, .cpp, .hh, .hpp
By:-Gourav Kottawar
7. Simple C++ program
7
#include <iostream.h>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
By:-Gourav Kottawar
8. Simple C++ program
8
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
By:-Gourav Kottawar
9. Simple C++ program
9
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
By:-Gourav Kottawar
10. namespace
Namespace is a new concept introduced by the
ANSI C++ standards committee.
This defines a scope for the identifiers that are
used in a program. For using the identifier defined
in the namespace scope we must include the
using directive, like
Using namespace std;
Here, std is the namespace where ANSI C++
standard class libraries are defined.
All ANSI C++ programs must include this
directive. This will bring all the identifiers defined in
std to the current global scope.
Using and namespace are the new keyword of
C++.
10
By:-Gourav Kottawar
11. Simple C++ program
11
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
By:-Gourav Kottawar
12. Simple C++ program
12
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
By:-Gourav Kottawar
15. Applications of C++
Since C++ allow us to create hierarchy related
objects, we can build special object-oriented
libraries which can be used later by many
programmers.
While C++ is able to map the real-world problem
properly, the C part of C++ gives the language the
ability to get closed to the machine-level details.
C++ programs are easily maintainable and
expandable. When a new feature needs to be
implemented, it is very easy to add to the existing
structure of an object.
• It is expected that C++ will replace C as a general-
purpose language in the near future.
15
By:-Gourav Kottawar