SlideShare a Scribd company logo
1 of 29
Object Oriented
Programming using C++
UGCA 1909
What is C++?
► C++ is a cross-platform language that can be used to create high-performance
applications.
► C++ was developed by Bjarne Stroustrup, as an extension to the C language.
► C++ gives programmers a high level of control over system resources and
memory.
Why Use C++?
► C++ is one of the world's most popular programming languages.
► C++ can be found in today's operating systems, Graphical User Interfaces, and
embedded systems.
► C++ is an object-oriented programming language which gives a clear structure to
programs and allows code to be reused, lowering development costs.
► C++ is portable and can be used to develop applications that can be adapted to
multiple platforms.
► C++ is fun and easy to learn!
Introduction to C++ Programming
Language
► C++ is a general-purpose programming language that was developed as an
enhancement of the C language to include object-oriented paradigm.
► It is a compiled language.
C vs. C++
What is C?
► C is a structural or procedural oriented programming language which is
machine-independent and extensively used in various applications.
► C is the basic programming language that can be used to develop from the
operating systems (like Windows) to complex programs like Oracle database,
Python interpreter, and many more.
► If we know the C language, then we can easily learn other programming
languages.
► C language was developed by the great computer scientist Dennis Ritchie at
the Bell Laboratories.
► It contains some additional features that make it unique from other
programming languages.
What is C++?
► C++ is a special-purpose programming language developed by Bjarne
Stroustrup at Bell Labs circa 1980.
► C++ language is very similar to C language, and it is so compatible with C that
it can run 99% of C programs without changing any source of code though C++
is an object-oriented programming language, so it is safer and well-structured
programming language than C.
C vs. C++
No. C C++
1) C follows the procedural style programming. C++ is multi-paradigm. It supports both procedural and object
oriented.
2) Data is less secured in C. In C++, you can use modifiers for class members to make it
inaccessible for outside users.
3) C follows the top-down approach. C++ follows the bottom-up approach.
4) C does not support function overloading. C++ supports function overloading.
5) In C, you can't use functions in structure. In C++, you can use functions in classes.
6) C does not support reference variables. C++ supports reference variables.
7) In C, scanf() and printf() are mainly used for input/output. C++ mainly uses stream cin and cout to perform input and
output operations.
8) Operator overloading is not possible in C. Operator overloading is possible in C++.
9) C programs are divided into procedures and modules C++ programs are divided into functions and classes.
10) C does not provide the feature of namespace. C++ supports the feature of namespace.
11) Exception handling is not easy in C. It has to perform using other
functions.
C++ provides exception handling using Try and Catch block.
12) C does not support the inheritance. C++ supports inheritance.
C++ history
► C++ programming language was developed in 1980 by Bjarne Stroustrup at bell
laboratories of AT&T (American Telephone & Telegraph), located in U.S.A.
► It was developed for adding a feature of OOP (Object Oriented Programming)
in C without significantly changing the C component.
► C++ programming is "relative" (called a superset) of C, it means any valid C
program is also a valid C++ program.
The History of C++
BCPL 1967
1970
1972
B
C
C++
ANSI C
1989
1983
Martin Richards.
No types
Ken Thompson
Dennis Ritchie
Some Types
The standard.
Strong Typing
Bjarne Stroustrup
OOP
C++ Features
► C++ is object oriented programming language. It provides a lot of features that are
given below.
1. Simple
2. Machine Independent or Portable
3. Mid-level programming language
4. Structured programming language
5. Rich Library
6. Memory Management
7. Fast Speed
8. Pointers
9. Recursion
10. Extensible
11. Object Oriented
12. Compiler based
C++ Features
Explanation
1) Simple
► C++ is a simple language in the sense that it provides structured approach (to
break the problem into parts), rich set of library functions, data types etc.
2) Machine Independent or Portable
► Unlike assembly language, c programs can be executed in many machines
with little bit or no change. But it is not platform-independent.
► A C++ program is not platform-independent (compiled programs on Linux
won't run on Windows), however they are machine independent.
3) Mid-level programming language
► C++ is also used to do low level programming. It is used to develop system
applications such as kernel, driver etc. It also supports the feature of high
level language. That is why it is known as mid-level language.
4) Structured programming language
► C++ is a structured programming language in the sense that we can break the
program into parts using functions. So, it is easy to understand and modify.
5) Rich Library
► C++ provides a lot of inbuilt functions that makes the development fast.
6) Memory Management
► It supports the feature of dynamic memory allocation. In C++ language, we can free
the allocated memory at any time by calling the free() function.
7) Speed
► The compilation and execution time of C++ language is fast.
8) Pointer
► C++ provides the feature of pointers. We can directly interact with the memory by
using the pointers. We can use pointers for memory, structures, functions, array
etc.
9) Recursion
► In C++, we can call the function within the function. It provides code reusability for
every function.
10) Extensible
► C++ language is extensible because it can easily adopt new features.
11) Object Oriented
► C++ is object oriented programming language. OOPs makes development and
maintenance easier where as in Procedure-oriented programming language it is not
easy to manage if code grows as project size grows.
12) Compiler based
► C++ is a compiler based programming language, it means without compilation no
C++ program can be executed. First we need to compile our program using compiler
and then we can execute our program.
OOPs (Object Oriented Programming
System)
► Object means a real word entity such as pen, chair, table etc.
► Object-Oriented Programming is a methodology or paradigm to design a program
using classes and objects.
► It simplifies the software development and maintenance by providing some
concepts:
► Object
► Class
► Inheritance
► Polymorphism
► Abstraction
► Encapsulation
OOPs Concepts
► Object
Any entity that has state and behavior is known as an object. For example: chair, pen,
table, keyboard, bike etc. It can be physical and logical.
► Class
Collection of objects is called class. It is a logical entity.
► Inheritance
When one object acquires all the properties and behaviours of parent object i.e. known as
inheritance. It provides code reusability. It is used to achieve runtime polymorphism.
► Polymorphism
When one task is performed by different ways i.e. known as polymorphism. For example: to
convince the customer differently, to draw something e.g. shape or rectangle etc.
In C++, we use Function overloading and Function overriding to achieve polymorphism.
► Abstraction
Hiding internal details and showing functionality is known as abstraction. For
example: phone call, we don't know the internal processing.
In C++, we use abstract class and interface to achieve abstraction.
► Encapsulation
Binding (or wrapping) code and data together into a single unit is known as
encapsulation. For example: capsule, it is wrapped with different medicines.
Advantage of OOPs over
Procedure-oriented programming
language
► OOPs makes development and maintenance easier where as in
Procedure-oriented programming language it is not easy to manage if code
grows as project size grows.
► OOPs provide data hiding whereas in Procedure-oriented programming
language a global data can be accessed from anywhere.
► OOPs provide ability to simulate real-world event much more effectively. We
can provide the solution of real word problem if we are using the Object-
Oriented Programming language.
Turbo C++ - Download & Installation
► There are many compilers available for C++. You need to download any one.
Here, we are going to use Turbo C++. It will work for both C and C++. To
install the Turbo C++ software, you need to follow following steps.
► Download Turbo C++
► Create turboc directory inside c drive and extract the tc3.zip inside c:turboc
► Double click on install.exe file
► Click on the tc application file located inside c:TCBIN to write the c program
C++ Program
#include <iostream.h>
#include<conio.h>
void main() {
clrscr();
cout << "Welcome to C++ Programming.";
getch();
}
Explanation
► #include<iostream.h> includes the standard input output library functions. It
provides cin and cout methods for reading from input and writing to output
respectively.
► #include <conio.h> includes the console input output library functions. The getch()
function is defined in conio.h file.
► void main() The main() function is the entry point of every program in C++ language.
The void keyword specifies that it returns no value.
► cout << "Welcome to C++ Programming." is used to print the data "Welcome to C++
Programming." on the console.
► getch() The getch() function asks for a single character. Until you press any key, it
blocks the screen.
How to compile and run the C++ program
► There are 2 ways to compile and run the C++ program, by menu and by shortcut.
► By menu
Now click on the compile menu then compile sub menu to compile the c++ program.
► Then click on the run menu then run sub menu to run the c++ program.
► By shortcut
Or, press ctrl+f9 keys compile and run the program directly.
Output screen
You can view the user screen any time by pressing the alt+f5 keys.
C++ Basic Input/Output
► C++ I/O operation is using the stream concept. Stream is the sequence of
bytes or flow of data. It makes the performance fast.
► If bytes flow from main memory to device like printer, display screen, or a
network connection, etc, this is called as output operation.
► If bytes flow from device like printer, display screen, or a network
connection, etc to main memory, this is called as input operation.
► <iostream> It is used to define the cout, cin and cerr objects, which
correspond to standard output stream, standard input stream and standard
error stream, respectively.
Standard output stream (cout)
► The cout is a predefined object of ostream class.
► It is connected with the standard output device, which is usually a display
screen.
► The cout is used in conjunction with stream insertion operator (<<) to display
the output on a console.
#include <iostream>
using namespace std;
int main( ) {
char a[] = "Welcome to C++ ";
cout << "Value of ary is: " << a << endl;
}
Output:
Value of a is: Welcome to C++
Standard input stream (cin)
► The cin is a predefined object of istream class.
► It is connected with the standard input device, which is usually a keyboard.
► The cin is used in conjunction with stream extraction operator (>>) to read
the input from a console.
#include <iostream>
using namespace std;
int main( ) {
int age;
cout << "Enter your age: ";
cin >> age;
cout << "Your age is: " << age << endl;
}
Output:
Enter your age: 22
Your age is: 22
Standard end line (endl)
► The endl is a predefined object of ostream class. It is used to insert a new
line characters and flushes the stream.
#include <iostream>
using namespace std;
int main( ) {
cout << "C++ ";
cout << " Program"<<endl;
cout << "End of line"<<endl;
}
Output:
C++ Program
End of line
object oriented programming language fundamentals

More Related Content

Similar to object oriented programming language fundamentals

Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++Manoj Kumar
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docMayurWagh46
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJmeharikiros2
 
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREC & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREjatin batra
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++Vaibhav Khanna
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxCoolGamer16
 
C++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTER
C++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTERC++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTER
C++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTERgroversimrans
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxAbdalla536859
 
C++ language basic
C++ language basicC++ language basic
C++ language basicWaqar Younis
 

Similar to object oriented programming language fundamentals (20)

C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
Session 1 - c++ intro
Session   1 - c++ introSession   1 - c++ intro
Session 1 - c++ intro
 
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTREC & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
C & C++ Training Centre in Ambala! BATRA COMPUTER CENTRE
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
Part 1
Part 1Part 1
Part 1
 
C++
C++C++
C++
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
 
C++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTER
C++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTERC++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTER
C++ TRAINING IN AMBALA CANTT! BATRA COMPUTER CENTER
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
basics of c++
basics of c++basics of c++
basics of c++
 
basics of c++
basics of c++basics of c++
basics of c++
 
Oops index
Oops indexOops index
Oops index
 
C vs c++
C vs c++C vs c++
C vs c++
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
 

Recently uploaded

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

object oriented programming language fundamentals

  • 2. What is C++? ► C++ is a cross-platform language that can be used to create high-performance applications. ► C++ was developed by Bjarne Stroustrup, as an extension to the C language. ► C++ gives programmers a high level of control over system resources and memory.
  • 3. Why Use C++? ► C++ is one of the world's most popular programming languages. ► C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems. ► C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs. ► C++ is portable and can be used to develop applications that can be adapted to multiple platforms. ► C++ is fun and easy to learn!
  • 4. Introduction to C++ Programming Language ► C++ is a general-purpose programming language that was developed as an enhancement of the C language to include object-oriented paradigm. ► It is a compiled language.
  • 5. C vs. C++ What is C? ► C is a structural or procedural oriented programming language which is machine-independent and extensively used in various applications. ► C is the basic programming language that can be used to develop from the operating systems (like Windows) to complex programs like Oracle database, Python interpreter, and many more. ► If we know the C language, then we can easily learn other programming languages. ► C language was developed by the great computer scientist Dennis Ritchie at the Bell Laboratories. ► It contains some additional features that make it unique from other programming languages.
  • 6. What is C++? ► C++ is a special-purpose programming language developed by Bjarne Stroustrup at Bell Labs circa 1980. ► C++ language is very similar to C language, and it is so compatible with C that it can run 99% of C programs without changing any source of code though C++ is an object-oriented programming language, so it is safer and well-structured programming language than C.
  • 7. C vs. C++ No. C C++ 1) C follows the procedural style programming. C++ is multi-paradigm. It supports both procedural and object oriented. 2) Data is less secured in C. In C++, you can use modifiers for class members to make it inaccessible for outside users. 3) C follows the top-down approach. C++ follows the bottom-up approach. 4) C does not support function overloading. C++ supports function overloading. 5) In C, you can't use functions in structure. In C++, you can use functions in classes. 6) C does not support reference variables. C++ supports reference variables. 7) In C, scanf() and printf() are mainly used for input/output. C++ mainly uses stream cin and cout to perform input and output operations. 8) Operator overloading is not possible in C. Operator overloading is possible in C++. 9) C programs are divided into procedures and modules C++ programs are divided into functions and classes. 10) C does not provide the feature of namespace. C++ supports the feature of namespace. 11) Exception handling is not easy in C. It has to perform using other functions. C++ provides exception handling using Try and Catch block. 12) C does not support the inheritance. C++ supports inheritance.
  • 8. C++ history ► C++ programming language was developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph), located in U.S.A. ► It was developed for adding a feature of OOP (Object Oriented Programming) in C without significantly changing the C component. ► C++ programming is "relative" (called a superset) of C, it means any valid C program is also a valid C++ program.
  • 9. The History of C++ BCPL 1967 1970 1972 B C C++ ANSI C 1989 1983 Martin Richards. No types Ken Thompson Dennis Ritchie Some Types The standard. Strong Typing Bjarne Stroustrup OOP
  • 10. C++ Features ► C++ is object oriented programming language. It provides a lot of features that are given below. 1. Simple 2. Machine Independent or Portable 3. Mid-level programming language 4. Structured programming language 5. Rich Library 6. Memory Management 7. Fast Speed 8. Pointers 9. Recursion 10. Extensible 11. Object Oriented 12. Compiler based
  • 12. Explanation 1) Simple ► C++ is a simple language in the sense that it provides structured approach (to break the problem into parts), rich set of library functions, data types etc. 2) Machine Independent or Portable ► Unlike assembly language, c programs can be executed in many machines with little bit or no change. But it is not platform-independent. ► A C++ program is not platform-independent (compiled programs on Linux won't run on Windows), however they are machine independent.
  • 13. 3) Mid-level programming language ► C++ is also used to do low level programming. It is used to develop system applications such as kernel, driver etc. It also supports the feature of high level language. That is why it is known as mid-level language. 4) Structured programming language ► C++ is a structured programming language in the sense that we can break the program into parts using functions. So, it is easy to understand and modify. 5) Rich Library ► C++ provides a lot of inbuilt functions that makes the development fast.
  • 14. 6) Memory Management ► It supports the feature of dynamic memory allocation. In C++ language, we can free the allocated memory at any time by calling the free() function. 7) Speed ► The compilation and execution time of C++ language is fast. 8) Pointer ► C++ provides the feature of pointers. We can directly interact with the memory by using the pointers. We can use pointers for memory, structures, functions, array etc. 9) Recursion ► In C++, we can call the function within the function. It provides code reusability for every function.
  • 15. 10) Extensible ► C++ language is extensible because it can easily adopt new features. 11) Object Oriented ► C++ is object oriented programming language. OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows. 12) Compiler based ► C++ is a compiler based programming language, it means without compilation no C++ program can be executed. First we need to compile our program using compiler and then we can execute our program.
  • 16. OOPs (Object Oriented Programming System) ► Object means a real word entity such as pen, chair, table etc. ► Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. ► It simplifies the software development and maintenance by providing some concepts: ► Object ► Class ► Inheritance ► Polymorphism ► Abstraction ► Encapsulation
  • 17. OOPs Concepts ► Object Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical. ► Class Collection of objects is called class. It is a logical entity. ► Inheritance When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism. ► Polymorphism When one task is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc. In C++, we use Function overloading and Function overriding to achieve polymorphism.
  • 18. ► Abstraction Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don't know the internal processing. In C++, we use abstract class and interface to achieve abstraction. ► Encapsulation Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines.
  • 19. Advantage of OOPs over Procedure-oriented programming language ► OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows. ► OOPs provide data hiding whereas in Procedure-oriented programming language a global data can be accessed from anywhere. ► OOPs provide ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object- Oriented Programming language.
  • 20. Turbo C++ - Download & Installation ► There are many compilers available for C++. You need to download any one. Here, we are going to use Turbo C++. It will work for both C and C++. To install the Turbo C++ software, you need to follow following steps. ► Download Turbo C++ ► Create turboc directory inside c drive and extract the tc3.zip inside c:turboc ► Double click on install.exe file ► Click on the tc application file located inside c:TCBIN to write the c program
  • 21. C++ Program #include <iostream.h> #include<conio.h> void main() { clrscr(); cout << "Welcome to C++ Programming."; getch(); }
  • 22. Explanation ► #include<iostream.h> includes the standard input output library functions. It provides cin and cout methods for reading from input and writing to output respectively. ► #include <conio.h> includes the console input output library functions. The getch() function is defined in conio.h file. ► void main() The main() function is the entry point of every program in C++ language. The void keyword specifies that it returns no value. ► cout << "Welcome to C++ Programming." is used to print the data "Welcome to C++ Programming." on the console. ► getch() The getch() function asks for a single character. Until you press any key, it blocks the screen.
  • 23. How to compile and run the C++ program ► There are 2 ways to compile and run the C++ program, by menu and by shortcut. ► By menu Now click on the compile menu then compile sub menu to compile the c++ program. ► Then click on the run menu then run sub menu to run the c++ program. ► By shortcut Or, press ctrl+f9 keys compile and run the program directly.
  • 24. Output screen You can view the user screen any time by pressing the alt+f5 keys.
  • 25. C++ Basic Input/Output ► C++ I/O operation is using the stream concept. Stream is the sequence of bytes or flow of data. It makes the performance fast. ► If bytes flow from main memory to device like printer, display screen, or a network connection, etc, this is called as output operation. ► If bytes flow from device like printer, display screen, or a network connection, etc to main memory, this is called as input operation. ► <iostream> It is used to define the cout, cin and cerr objects, which correspond to standard output stream, standard input stream and standard error stream, respectively.
  • 26. Standard output stream (cout) ► The cout is a predefined object of ostream class. ► It is connected with the standard output device, which is usually a display screen. ► The cout is used in conjunction with stream insertion operator (<<) to display the output on a console. #include <iostream> using namespace std; int main( ) { char a[] = "Welcome to C++ "; cout << "Value of ary is: " << a << endl; } Output: Value of a is: Welcome to C++
  • 27. Standard input stream (cin) ► The cin is a predefined object of istream class. ► It is connected with the standard input device, which is usually a keyboard. ► The cin is used in conjunction with stream extraction operator (>>) to read the input from a console. #include <iostream> using namespace std; int main( ) { int age; cout << "Enter your age: "; cin >> age; cout << "Your age is: " << age << endl; } Output: Enter your age: 22 Your age is: 22
  • 28. Standard end line (endl) ► The endl is a predefined object of ostream class. It is used to insert a new line characters and flushes the stream. #include <iostream> using namespace std; int main( ) { cout << "C++ "; cout << " Program"<<endl; cout << "End of line"<<endl; } Output: C++ Program End of line