SlideShare a Scribd company logo
S.Y.B.C.A.(Science)
BCA 241-Object Oriented Programming And C++
Unit 1
Introduction to C++
Prepared by:
Prof. Shashi Jadhav
Modern college, Ganeshkhind,Pune.
Unit 1 introduction to c++.pptx
Introduction
• What is Programming Language?
A programming language is a type of written language that tells
computers what to do.
Examples are: Python, Ruby, Java, JavaScript, C, C++, and C#.
Programming languages are used to write all computer programs and
computer software.
• Types of Computer Languages
1. Machine level
2. Assembly level
3. High level
High level languages
1. Procedure Oriented: C, Fortran,COBOL, VB, and Pascal.
2 Object oriented: Java, C++, VB.NET, Python, and C#.NET.
Procedure-oriented programming.
• Programming in the high-level languages such as COBOL, FORTRAN, C,
etc. is known as procedure-oriented programming.
• Procedure-oriented programming basically contains group of
instructions known as function. There are multiple functions into the
program.
• In below figure we have divided our program into multiple functions.
• We use flowchart or algorithm to show how the program is executed
from one instruction to other instruction.
• It doesn’t emphasize on the data.
Unit 1 introduction to c++.pptx
• In a multi-function program we use
global variable to communicate
between two functions.
• Global variable can be use by any
function at any time while local
variables are only used within the
function.
• But it creates problem in large
program because we can’t
determine which global variables
(data) are used by which function.
• Also global variables are accessed
by all the function so any function
can change its value at any time so
all the function will be affected.
Characteristics of procedure-oriented
programming language:
• It emphasis on algorithm (focus is on doing things/functions ).
• Large programs are divided into smaller programs known as
functions. Hence the program consist of multiple functions.
• Most of the Functions share global data.
• Data is not hidden, it move freely from one function to another
function.
• Functions change the value of data at any time from any place.
(Functions transform data from one form to another.)
• Hence no data security.
• It uses top-down programming approach.
Drawbacks Of POP
• POP has two major drawbacks, viz.
• (1) data move freely around the program and are therefore
vulnerable to changes caused by any function in the program, and
• (2) it does not model very well the real-world problems.
Object-oriented programming
• Object-oriented programming
(OOP) is a computer programming
model that organizes software
design around data, or objects,
rather than functions and logic.
• OOP allows decomposition of a
problem into a number of entities
called objects and then builds data
& functions around these objects.
• The data of an object can be
accessed by only the function
associated with that object.
• However functions of one object
can be accessed by functions of
another object.
Object-oriented programming
• Striking features of object oriented programming are :
• Emphasis is on data rather than procedure.
• Programs are divided into objects.
• Data structures are designed such that they characterize the objects.
• Functions that operate on the data of an object are tied together in
the data structure.
• Data is hidden and cannot be accessed by external functions.
• Objects may communicate with each other through functions.
• New data and functions can be easily added whenever necessary.
• Follows bottom-up approach in program design.
BASIC CONCEPTS OF OBJECT-ORIENTED
PROGRAMMING
The basic concepts of object oriented programming include :
• Objects
• Classes
• Data abstraction and encapsulation
• Inheritance
• Polymorphism
• Data binding
• Message passing.
Advantages of OOP
• Re-usability: Write once and use it multiple times, you can achieve this by using
class.
• Redundancy: This is a condition created at the place of data storage (you can say
Databases)where the same piece of data is held in two separate places. So the
data redundancy is one of the greatest advantages of OOP. If a user wants a
similar functionality in multiple classes, he/she can go ahead by writing common
class definitions for similar functionalities and inherit them.
• Easy Maintenance: It is easy to maintain and modify existing code, as new objects
can be created with small differences to existing ones.
• Code Flexibility
The flexibility is offered through the concept of Polymorphism.
• Security: Using data hiding and abstraction only necessary data will be provided,
thus maintains the security of data.
Disadvantages of OOP:
• Size: Object-Oriented Programs are much larger than other programs.
• Effort: Object-Oriented Programs require a lot of work to create.
• Speed: Object-Oriented Programs are slower than other programs,
because of their size.
Applications of object oriented programming
• 1.Developing graphical user interface
• 2.System Applications
• 3. Object oriented database system
• 4.Expert Systems
• 5. Simulation and modelling softwares
• 6. Artificial intelligence
• 7 Compiler construction
• 8 CAD/CAM software
Unit 1 introduction to c++.pptx
OOP Vs POP
Sr. No. Key OOP POP
1
Definition OOP stands for Object Oriented
Programing.
POP stands for Procedural
Oriented Programming.
2 Approach OOP follows bottom up approach. POP follows top down approach.
3
Division A program is divided to objects
and their interactions.
A program is divided into funtions
and they interacts.
4
Inheritance
supported
Inheritance is supported. Inheritance is not supported.
5
Access
control
Access control is supported via
access modifiers.
No access modifiers are
supported.
6
Data Hiding Encapsulation is used to hide data. No data hiding present. Data is
globally accessible.
7 Example C++, Java C, Pascal
Introduction to C++
It is an object oriented programming language.
Evolved in 1979,by Bjarne Stroustrup at AT & T Bell laboratories.
It is based on an object oriented language Simula67 and C language.
C++ is an extention of C with a major addition of the class construct
feature of Simula67.
Initially it was called as C with classes.
In 1983 it was renamed as C++(incremented version of C)
C++ is a superset of C
Backward compatible to C i.e. Almost all C programs are also C++
programs.
Applications of C++
• Versatile language for handling very large programs.
• Suitable for development of editors, databases, System programs.
• Useful for developing good libraries which can be later used by many
programmers.
• C++ is used in developing browsers, operating systems, and
applications, as well as in-game programming, software engineering,
data structures, etc.
• JVM(virtual machine of Java) and python interpreter are written in
C++.
Advantages of C++ Over Other Languages
• 1. Object-Oriented
C++ is an object-oriented programming language which means that the main focus is on objects and manipulations around
these objects. This makes it much easier to manipulate code, unlike procedural or structured programming which requires a
series of computational steps to be carried out.
• 2. Speed
When speed is a critical metric, C++ is the most preferred choice. The compilation and execution time of a C++ program is
much faster than most general-purpose programming languages.
• 3. Compiled
Unlike other programming languages where no compilation is required, every C++ code has to be first compiled to a low-level
language and then executed. Hence faster and more efficient to execute than interpreted languages.
• 4. Rich Library Support
The C++ Standard Template Library (STL) has many functions available to help write code quickly. For example, there are STLs
for various containers like hash tables, maps, sets, etc.
• 5. Pointer Support
C++ also supports pointers which are often not available in other programming languages.
• 6. Closer to Hardware
C++ is closer to hardware than most general-purpose programming languages. This makes it very useful in those areas where
hardware and software are closely coupled together, and low-level support is needed at the software level. Developer has
more control over hardware aspects, like memory management and CPU usage.
Features of C++
1) Simple
C++ is a simple language because it provides a structured approach (to
break the problem into parts), a rich set of library functions, data types,
etc.
2) Abstract Data types
In C++, complex data types called Abstract Data Types (ADT) can be
created using classes.
3) Portable
• C++ is a portable language and programs made in it can be run on
different machines.
Features of C++
4) Mid-level / Intermediate programming language
C++ includes both low-level programming and high-level language so it is known as
a mid-level and intermediate programming language. It is used to develop system
applications such as kernel, driver, etc.
5) Structured programming language
C++ is a structured programming language. In this we can divide the program into
several parts using functions.
6) Rich Library
C++ provides a lot of inbuilt functions that make the development fast. Following
are the libraries used in C++ programming are:
• <iostream>
• <cmath>
• <cstdlib>
• <fstream>
Features of C++
7) Memory Management
• C++ provides very efficient management techniques. The various memory
management operators help save the memory and improve the program's
efficiency. These operators allocate and deallocate memory at run time.
Some common memory management operators available C++ are new,
delete etc.
8) Quicker Compilation
• C++ programs tend to be compact and run quickly. Hence the compilation
and execution time of the C++ language is fast.
9) Pointer
• C++ provides the feature of pointers. We can use pointers for memory,
structures, functions, array, etc. We can directly interact with the memory
by using the pointers.
10) Recursion
• In C++, we can call the function within the function. It provides code
reusability for every function.
Features of C++
11) Extensible
• C++ programs can easily be extended as it is very easy to add new
features into the existing program.
12) Object-Oriented
• In C++, object-oriented concepts like data hiding, encapsulation, and
data abstraction can easily be implemented using keyword class,
private, public, and protected access specifiers. Object-oriented
makes development and maintenance easier.
13) Compiler based
• C++ is a compiler-based programming language, which means no C++
program can be executed without compilation. C++ compiler is easily
available, and it requires very little space for storage. First, we need to
compile our program using a compiler, and then we can execute our
program.
Features of C++
14) Reusability
• With the use of inheritance of functions programs written in C++ can be
reused in any other program of C++. You can save program parts into
library files and invoke them in your next programming projects simply by
including the library files. New programs can be developed in lesser time as
the existing code can be reused. It is also possible to define several
functions with same name that perform different task. For Example: abs ()
is used to calculate the absolute value of integer, float and long integer.
• 15) Redefine Existing Operators
• C++ allows the programmer to redefine the meaning of existing operators
such as +, -. For Example, The "+" operator can be used for adding two
numbers and concatenating two strings.
Features of C++
16)National Standards
• C++ has national standards such as ANSI. (American National
Standards Institute)
17) Errors are easily detected
• It is easier to maintain a C++ programs as errors can be easily located
and rectified. It also provides a feature called exception handling to
support error handling in your program.
18) Clarity
• The keywords and library functions used in C++ resemble common
English words.
Features of C++
19) Power and Flexibility
• C++ is a powerful and flexible language because of most of the
powerful flexible and modern UNIX operating system is written in
C++. Many compilers and interpreters for other languages such as
FORTRAN, PERL, Python, PASCAL, BASIC, LISP, etc., have been written
in C++. C++ programs have been used for solving physics and
engineering problems and even for animated special effects for
movies.
20) Modelling real-world problems
• The programs written in C++ are well suited for real-world modeling
problems as close as possible to the user perspective.
Differences between C and C++:
• Definition
C is a structural programming language, and it does not support classes and
objects, while C++ is an object-oriented programming language that supports the
concept of classes and objects.
• Type of programming language
C is procedure oriented programming language(POP) , while C++ is an object-
oriented programming language(OOP).
• Subset
C++ is a superset of C programming language. C++ can run 99% of C code but C
language cannot run C++ code.
• Type of approach
C follows the top-down approach, while C++ follows the bottom-up approach.
The top-down approach breaks the main modules into tasks; these tasks are
broken into sub-tasks, and so on. The bottom-up approach develops the lower
level modules first and then the next level modules.
Differences between C and C++:
• Keywords
C contains 32 keywords, and C++ supports 63 keywords.(81 as of C++20)
• Security
In C, the data can be easily manipulated by the outsiders as it does not support
the encapsulation and information hiding while C++ is a very secure language,
i.e., no outsiders can manipulate its data as it supports both encapsulation and
data hiding. In C language, functions and data are the free entities, and in C++
language, all the functions and data are encapsulated in the form of objects.
• Exception handling
C does not provide direct support to the exception handling; it needs to use
functions that support exception handling. C++ provides direct support to
exception handling by using a try-catch block.
• Input/Output functions
In C, scanf and printf functions are used for input and output operations,
respectively, while in C++, cin and cout are used for input and output operations,
respectively.
Differences between C and C++:
• Memory allocation and de-allocation
C supports calloc() and malloc() functions for the memory allocation, and free()
function for the memory de-allocation. C++ supports a new operator for the
memory allocation and delete operator for the memory de-allocation.
• Header file
C program uses <stdio.h> header file while C++ program
uses <iostream.h> header file.
• Namespace feature
A namespace is a feature that groups the entities like classes, objects, and
functions under some specific name. C does not contain the namespace feature,
while C++ supports the namespace feature that avoids the name collisions.
Writing and executing a C++ Program
Step1.
Creating source code Using Vi Editor :
• Open terminal
• write command vi filename.cpp” for C++ (“vi filename.c” For C)
• Enter “I” , to activate insert mode in vi editor .
• Write your code
• Enter “Esc”
• Enter “:”
• write “wq” ,Enter.
• Now source file is created with .cpp extention
• Step 2:
• Compiling the source code:
• The source file has to be converted into machine code using a
compiler. For this we can use Turbo C++ or GNU C++ Compiler
• Using GNU C++ Compiler gcc or g++:
• for cpp code write “g++ - o filename filename.cpp” , Or write “g++
filename.cpp”
• (for c code write “gcc - o filename filename.c” ,Enter)
• After compiling a runnable file will be created which is called
object file .(with extention .o/.obj)
• Step3:
• Linking the object code to create an Executable code-
• After compilation the object file is given to linker.
• This program combines the files, add necessary libraries and creates
an executable file with extension .exe
• Step4
• Executing the Program
• Once the executable file is created, you can run it by typing its name
at the DOS command prompt or through the option provided by the
compiler software.
• In linux /centos you can write ./filename or ./a.out and press enter.
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptx
Simple C++ Program • #include <iostream> is Directives for
preprocessor:
• A namespace is a feature that groups
the entities like classes, objects, and
functions under some specific name.
• As the same name can’t be given to
multiple variables, functions, classes,
etc. in the same scope.
• So to overcome this situation
namespace is introduced.
• namespace defines a scope of that
entity.
• std is a namespace whose members
are used in the program
the members of the “std” namespace
are cout, cin, endl, etc.
• int main() : It is Function Signatures
#include <iostream>
using namespace std;
namespace sybca // first name space
{
void show_topper()
{ cout << "Raj is topper"<< endl;
}
}
// second name space
namespace tybca
{
void show_topper()
{
cout << "Radha is topper"<< endl;
}
}
using namespace sybca;
int main ()
{
show_topper();
return 0;
}
•What is output ??
•Rewrite same program
without using
namespace
Directives: #include <iostream>
• In the first line, the file iostream is included into the current .cpp file.
The hashtag (#) signals to a program called the preprocessor which
reads through your source code, looking for all the lines that begin
the with # symbol. The command #include tells the preprocessor
“find the file iostream, read it, and place it here.” The angle brackets
(<>) surrounding the file name tells the preprocessor to look in the
usual places for this file. If your compiler is set up properly, all the
include files are in one repository.
• The file iostream is used by cout, which writes to the console. The
effect of #include <iostream> is to include the file iostream into this
C++ program as if you typed it in yourself.
Function Signatures: int main()
• The actual program begins with the function main(). Every C++ program
needs to have a main() function because when you execute your program,
main() is called automatically.
• A function’s signature is important because it defines the inputs and
outputs of the function. In int main(), the first part int states that the
main() function returns an interger value to the operating system. This
function achieves that because, at the bottom, it executes return 0.
• Note: The compiler will allow you to return other data types. However, for
main(), the only legal return type is int. Generally, it is the informal
convention to return 0 to express that the program has ended without
errors.
The Function Body & Namespaces
• All functions begin with an opening brace ({) and end with a closing brace
(}). Everything in between the braces is considered to be part of that
function.
• cout and cin are used in C++ to handle input (such as user input from a
keyboard) and output (such as printing to the console).
• cout and cin objects provided by the standard library (std)
• The standard library is the standard collection of objects that comes with
every C++ compiler.
• By using the namespace specifier std,
You tell the compiler that the cout object you can use is part of the standard
library
Assignment 1
• Q1. Explain features of C++ language?
• Q2.What are advantages of C++ ?
• Q3. What is Procedure Oriented Programming?
• Q4. What is object Oriented Programming?
• Q5. Write advantages and limitations of object oriented
programming.
Ad

More Related Content

What's hot (20)

Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
foreverredpb
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
Marwa Ali Eissa
 
Poo encapsulamento
Poo encapsulamentoPoo encapsulamento
Poo encapsulamento
Sedu
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
Nilesh Dalvi
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
Ankur Goyal
 
Classes&amp;objects
Classes&amp;objectsClasses&amp;objects
Classes&amp;objects
M Vishnuvardhan Reddy
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
ppd1961
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
Doncho Minkov
 
OOP java
OOP javaOOP java
OOP java
xball977
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Vb.net (loop structure)
Vb.net (loop structure)Vb.net (loop structure)
Vb.net (loop structure)
Abhishek Pachisia
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
vikram mahendra
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
Mayank Jain
 
Friend function in c++
Friend function in c++ Friend function in c++
Friend function in c++
University of Madras
 
User defined function in c
User defined function in cUser defined function in c
User defined function in c
JeevanandhamSubraman
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
Jussi Pohjolainen
 
Java string handling
Java string handlingJava string handling
Java string handling
Salman Khan
 
Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introduction
Sohanur63
 
Programação orientada a objetos – II
Programação orientada a objetos – IIProgramação orientada a objetos – II
Programação orientada a objetos – II
Gabriel Faustino
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
foreverredpb
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
Marwa Ali Eissa
 
Poo encapsulamento
Poo encapsulamentoPoo encapsulamento
Poo encapsulamento
Sedu
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
Nilesh Dalvi
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
Ankur Goyal
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
ppd1961
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
Doncho Minkov
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
vikram mahendra
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
Mayank Jain
 
Java string handling
Java string handlingJava string handling
Java string handling
Salman Khan
 
Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introduction
Sohanur63
 
Programação orientada a objetos – II
Programação orientada a objetos – IIProgramação orientada a objetos – II
Programação orientada a objetos – II
Gabriel Faustino
 

Similar to Unit 1 introduction to c++.pptx (20)

Object Oriented programming - Introduction
Object Oriented programming - IntroductionObject Oriented programming - Introduction
Object Oriented programming - Introduction
Madishetty Prathibha
 
C++
C++C++
C++
SamreenShaikh26
 
Unit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.pptUnit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.ppt
hannahroseline2
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
Shipra Swati
 
Programming using C++ - slides.pptx
Programming using C++ - slides.pptxProgramming using C++ - slides.pptx
Programming using C++ - slides.pptx
HeadoftheDepartment
 
OOP-1.pptx
OOP-1.pptxOOP-1.pptx
OOP-1.pptx
iansebuabeh
 
C-and-Cpp-Brochure-English. .
C-and-Cpp-Brochure-English.               .C-and-Cpp-Brochure-English.               .
C-and-Cpp-Brochure-English. .
spotguys705
 
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
vyshnavzpradeep619
 
Oop basic overview
Oop basic overviewOop basic overview
Oop basic overview
Deborah Akuoko
 
Unit 1
Unit 1Unit 1
Unit 1
ankita1317
 
JAVA
JAVAJAVA
JAVA
sonali_iul
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
AKR Education
 
object oriented programming in c++ introduction lecture 1.pptx
object oriented programming in c++ introduction lecture 1.pptxobject oriented programming in c++ introduction lecture 1.pptx
object oriented programming in c++ introduction lecture 1.pptx
amna hussain
 
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptxUNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
RoselinLourd
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docx
prakashvs7
 
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
jatin batra
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
Rai University
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
Rai University
 
Part 1
Part 1Part 1
Part 1
Moatez Amairi
 
chapter _3.pptx Programming Language in DSS
chapter _3.pptx Programming Language in DSSchapter _3.pptx Programming Language in DSS
chapter _3.pptx Programming Language in DSS
KeenboonAsaffaa
 
Object Oriented programming - Introduction
Object Oriented programming - IntroductionObject Oriented programming - Introduction
Object Oriented programming - Introduction
Madishetty Prathibha
 
Unit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.pptUnit 1- Basic concept of object-oriented-programming.ppt
Unit 1- Basic concept of object-oriented-programming.ppt
hannahroseline2
 
Programming using C++ - slides.pptx
Programming using C++ - slides.pptxProgramming using C++ - slides.pptx
Programming using C++ - slides.pptx
HeadoftheDepartment
 
C-and-Cpp-Brochure-English. .
C-and-Cpp-Brochure-English.               .C-and-Cpp-Brochure-English.               .
C-and-Cpp-Brochure-English. .
spotguys705
 
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
C+Comprehensive overview of the IoT system aims, architecture, challenges, ap...
vyshnavzpradeep619
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
AKR Education
 
object oriented programming in c++ introduction lecture 1.pptx
object oriented programming in c++ introduction lecture 1.pptxobject oriented programming in c++ introduction lecture 1.pptx
object oriented programming in c++ introduction lecture 1.pptx
amna hussain
 
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptxUNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
RoselinLourd
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docx
prakashvs7
 
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
jatin batra
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
Rai University
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
Rai University
 
chapter _3.pptx Programming Language in DSS
chapter _3.pptx Programming Language in DSSchapter _3.pptx Programming Language in DSS
chapter _3.pptx Programming Language in DSS
KeenboonAsaffaa
 
Ad

Recently uploaded (20)

4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
abayamargaug
 
Antonie van Leeuwenhoek- Father of Microbiology
Antonie van Leeuwenhoek- Father of MicrobiologyAntonie van Leeuwenhoek- Father of Microbiology
Antonie van Leeuwenhoek- Father of Microbiology
Anoja Kurian
 
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,PhosphorosClass-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
govindapathak8
 
UNIT chromatography instrumental6 .pptx
UNIT chromatography  instrumental6 .pptxUNIT chromatography  instrumental6 .pptx
UNIT chromatography instrumental6 .pptx
myselfit143
 
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Yasasi Abeysinghe
 
Effect of nutrition in Entomophagous Insectson
Effect of nutrition in Entomophagous InsectsonEffect of nutrition in Entomophagous Insectson
Effect of nutrition in Entomophagous Insectson
JabaskumarKshetri
 
Lecture 12 Types of farming system
Lecture 12       Types of farming systemLecture 12       Types of farming system
Lecture 12 Types of farming system
Nickala1
 
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
Sérgio Sacani
 
RAPID DIAGNOSTIC TEST (RDT) overviewppt.pptx
RAPID DIAGNOSTIC TEST (RDT)  overviewppt.pptxRAPID DIAGNOSTIC TEST (RDT)  overviewppt.pptx
RAPID DIAGNOSTIC TEST (RDT) overviewppt.pptx
nietakam
 
Multydisciplinary Nature of Environmental Studies
Multydisciplinary Nature of Environmental StudiesMultydisciplinary Nature of Environmental Studies
Multydisciplinary Nature of Environmental Studies
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
SuperconductingMagneticEnergyStorage.pptx
SuperconductingMagneticEnergyStorage.pptxSuperconductingMagneticEnergyStorage.pptx
SuperconductingMagneticEnergyStorage.pptx
BurkanAlpKale
 
Nutritional Diseases in poultry.........
Nutritional Diseases in poultry.........Nutritional Diseases in poultry.........
Nutritional Diseases in poultry.........
Bangladesh Agricultural University,Mymemsingh
 
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Gender Bias and Empathy in Robots:  Insights into Robotic Service FailuresGender Bias and Empathy in Robots:  Insights into Robotic Service Failures
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Selcen Ozturkcan
 
whole ANATOMY OF EYE with eye ball .pptx
whole ANATOMY OF EYE with eye ball .pptxwhole ANATOMY OF EYE with eye ball .pptx
whole ANATOMY OF EYE with eye ball .pptx
simranjangra13
 
Polytene chromosomes. A Practical Lecture.pptx
Polytene chromosomes. A Practical Lecture.pptxPolytene chromosomes. A Practical Lecture.pptx
Polytene chromosomes. A Practical Lecture.pptx
Dr Showkat Ahmad Wani
 
Skin_Glands_Structure_Secretion _Control
Skin_Glands_Structure_Secretion _ControlSkin_Glands_Structure_Secretion _Control
Skin_Glands_Structure_Secretion _Control
muralinath2
 
Metallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda PathakMetallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda Pathak
GovindaPathak6
 
Concise Notes on tree and graph data structure
Concise Notes on tree and graph data structureConcise Notes on tree and graph data structure
Concise Notes on tree and graph data structure
YekoyeTigabu2
 
biochemistry amino acid from chemistry to life machinery
biochemistry amino acid from chemistry to life machinerybiochemistry amino acid from chemistry to life machinery
biochemistry amino acid from chemistry to life machinery
chaitanyaa4444
 
Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...
Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...
Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...
Himarsha Jayanetti
 
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
4. Chapter 4 - FINAL Promoting Inclusive Culture (2).pdf
abayamargaug
 
Antonie van Leeuwenhoek- Father of Microbiology
Antonie van Leeuwenhoek- Father of MicrobiologyAntonie van Leeuwenhoek- Father of Microbiology
Antonie van Leeuwenhoek- Father of Microbiology
Anoja Kurian
 
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,PhosphorosClass-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
Class-11-notes- Inorganic Chemistry Hydrogen, Oxygen,Ozone,Carbon,Phosphoros
govindapathak8
 
UNIT chromatography instrumental6 .pptx
UNIT chromatography  instrumental6 .pptxUNIT chromatography  instrumental6 .pptx
UNIT chromatography instrumental6 .pptx
myselfit143
 
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Examining Visual Attention in Gaze-Driven VR Learning: An Eye-Tracking Study ...
Yasasi Abeysinghe
 
Effect of nutrition in Entomophagous Insectson
Effect of nutrition in Entomophagous InsectsonEffect of nutrition in Entomophagous Insectson
Effect of nutrition in Entomophagous Insectson
JabaskumarKshetri
 
Lecture 12 Types of farming system
Lecture 12       Types of farming systemLecture 12       Types of farming system
Lecture 12 Types of farming system
Nickala1
 
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5On the Lunar Origin of Near-Earth Asteroid 2024 PT5
On the Lunar Origin of Near-Earth Asteroid 2024 PT5
Sérgio Sacani
 
RAPID DIAGNOSTIC TEST (RDT) overviewppt.pptx
RAPID DIAGNOSTIC TEST (RDT)  overviewppt.pptxRAPID DIAGNOSTIC TEST (RDT)  overviewppt.pptx
RAPID DIAGNOSTIC TEST (RDT) overviewppt.pptx
nietakam
 
SuperconductingMagneticEnergyStorage.pptx
SuperconductingMagneticEnergyStorage.pptxSuperconductingMagneticEnergyStorage.pptx
SuperconductingMagneticEnergyStorage.pptx
BurkanAlpKale
 
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Gender Bias and Empathy in Robots:  Insights into Robotic Service FailuresGender Bias and Empathy in Robots:  Insights into Robotic Service Failures
Gender Bias and Empathy in Robots: Insights into Robotic Service Failures
Selcen Ozturkcan
 
whole ANATOMY OF EYE with eye ball .pptx
whole ANATOMY OF EYE with eye ball .pptxwhole ANATOMY OF EYE with eye ball .pptx
whole ANATOMY OF EYE with eye ball .pptx
simranjangra13
 
Polytene chromosomes. A Practical Lecture.pptx
Polytene chromosomes. A Practical Lecture.pptxPolytene chromosomes. A Practical Lecture.pptx
Polytene chromosomes. A Practical Lecture.pptx
Dr Showkat Ahmad Wani
 
Skin_Glands_Structure_Secretion _Control
Skin_Glands_Structure_Secretion _ControlSkin_Glands_Structure_Secretion _Control
Skin_Glands_Structure_Secretion _Control
muralinath2
 
Metallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda PathakMetallurgical process class 11_Govinda Pathak
Metallurgical process class 11_Govinda Pathak
GovindaPathak6
 
Concise Notes on tree and graph data structure
Concise Notes on tree and graph data structureConcise Notes on tree and graph data structure
Concise Notes on tree and graph data structure
YekoyeTigabu2
 
biochemistry amino acid from chemistry to life machinery
biochemistry amino acid from chemistry to life machinerybiochemistry amino acid from chemistry to life machinery
biochemistry amino acid from chemistry to life machinery
chaitanyaa4444
 
Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...
Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...
Infrastructure for Tracking Information Flow from Social Media to U.S. TV New...
Himarsha Jayanetti
 
Ad

Unit 1 introduction to c++.pptx

  • 1. S.Y.B.C.A.(Science) BCA 241-Object Oriented Programming And C++ Unit 1 Introduction to C++ Prepared by: Prof. Shashi Jadhav Modern college, Ganeshkhind,Pune.
  • 3. Introduction • What is Programming Language? A programming language is a type of written language that tells computers what to do. Examples are: Python, Ruby, Java, JavaScript, C, C++, and C#. Programming languages are used to write all computer programs and computer software. • Types of Computer Languages 1. Machine level 2. Assembly level 3. High level
  • 4. High level languages 1. Procedure Oriented: C, Fortran,COBOL, VB, and Pascal. 2 Object oriented: Java, C++, VB.NET, Python, and C#.NET.
  • 5. Procedure-oriented programming. • Programming in the high-level languages such as COBOL, FORTRAN, C, etc. is known as procedure-oriented programming. • Procedure-oriented programming basically contains group of instructions known as function. There are multiple functions into the program. • In below figure we have divided our program into multiple functions. • We use flowchart or algorithm to show how the program is executed from one instruction to other instruction. • It doesn’t emphasize on the data.
  • 7. • In a multi-function program we use global variable to communicate between two functions. • Global variable can be use by any function at any time while local variables are only used within the function. • But it creates problem in large program because we can’t determine which global variables (data) are used by which function. • Also global variables are accessed by all the function so any function can change its value at any time so all the function will be affected.
  • 8. Characteristics of procedure-oriented programming language: • It emphasis on algorithm (focus is on doing things/functions ). • Large programs are divided into smaller programs known as functions. Hence the program consist of multiple functions. • Most of the Functions share global data. • Data is not hidden, it move freely from one function to another function. • Functions change the value of data at any time from any place. (Functions transform data from one form to another.) • Hence no data security. • It uses top-down programming approach.
  • 9. Drawbacks Of POP • POP has two major drawbacks, viz. • (1) data move freely around the program and are therefore vulnerable to changes caused by any function in the program, and • (2) it does not model very well the real-world problems.
  • 10. Object-oriented programming • Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. • OOP allows decomposition of a problem into a number of entities called objects and then builds data & functions around these objects. • The data of an object can be accessed by only the function associated with that object. • However functions of one object can be accessed by functions of another object.
  • 11. Object-oriented programming • Striking features of object oriented programming are : • Emphasis is on data rather than procedure. • Programs are divided into objects. • Data structures are designed such that they characterize the objects. • Functions that operate on the data of an object are tied together in the data structure. • Data is hidden and cannot be accessed by external functions. • Objects may communicate with each other through functions. • New data and functions can be easily added whenever necessary. • Follows bottom-up approach in program design.
  • 12. BASIC CONCEPTS OF OBJECT-ORIENTED PROGRAMMING The basic concepts of object oriented programming include : • Objects • Classes • Data abstraction and encapsulation • Inheritance • Polymorphism • Data binding • Message passing.
  • 13. Advantages of OOP • Re-usability: Write once and use it multiple times, you can achieve this by using class. • Redundancy: This is a condition created at the place of data storage (you can say Databases)where the same piece of data is held in two separate places. So the data redundancy is one of the greatest advantages of OOP. If a user wants a similar functionality in multiple classes, he/she can go ahead by writing common class definitions for similar functionalities and inherit them. • Easy Maintenance: It is easy to maintain and modify existing code, as new objects can be created with small differences to existing ones. • Code Flexibility The flexibility is offered through the concept of Polymorphism. • Security: Using data hiding and abstraction only necessary data will be provided, thus maintains the security of data.
  • 14. Disadvantages of OOP: • Size: Object-Oriented Programs are much larger than other programs. • Effort: Object-Oriented Programs require a lot of work to create. • Speed: Object-Oriented Programs are slower than other programs, because of their size.
  • 15. Applications of object oriented programming • 1.Developing graphical user interface • 2.System Applications • 3. Object oriented database system • 4.Expert Systems • 5. Simulation and modelling softwares • 6. Artificial intelligence • 7 Compiler construction • 8 CAD/CAM software
  • 17. OOP Vs POP Sr. No. Key OOP POP 1 Definition OOP stands for Object Oriented Programing. POP stands for Procedural Oriented Programming. 2 Approach OOP follows bottom up approach. POP follows top down approach. 3 Division A program is divided to objects and their interactions. A program is divided into funtions and they interacts. 4 Inheritance supported Inheritance is supported. Inheritance is not supported. 5 Access control Access control is supported via access modifiers. No access modifiers are supported. 6 Data Hiding Encapsulation is used to hide data. No data hiding present. Data is globally accessible. 7 Example C++, Java C, Pascal
  • 18. Introduction to C++ It is an object oriented programming language. Evolved in 1979,by Bjarne Stroustrup at AT & T Bell laboratories. It is based on an object oriented language Simula67 and C language. C++ is an extention of C with a major addition of the class construct feature of Simula67. Initially it was called as C with classes. In 1983 it was renamed as C++(incremented version of C) C++ is a superset of C Backward compatible to C i.e. Almost all C programs are also C++ programs.
  • 19. Applications of C++ • Versatile language for handling very large programs. • Suitable for development of editors, databases, System programs. • Useful for developing good libraries which can be later used by many programmers. • C++ is used in developing browsers, operating systems, and applications, as well as in-game programming, software engineering, data structures, etc. • JVM(virtual machine of Java) and python interpreter are written in C++.
  • 20. Advantages of C++ Over Other Languages • 1. Object-Oriented C++ is an object-oriented programming language which means that the main focus is on objects and manipulations around these objects. This makes it much easier to manipulate code, unlike procedural or structured programming which requires a series of computational steps to be carried out. • 2. Speed When speed is a critical metric, C++ is the most preferred choice. The compilation and execution time of a C++ program is much faster than most general-purpose programming languages. • 3. Compiled Unlike other programming languages where no compilation is required, every C++ code has to be first compiled to a low-level language and then executed. Hence faster and more efficient to execute than interpreted languages. • 4. Rich Library Support The C++ Standard Template Library (STL) has many functions available to help write code quickly. For example, there are STLs for various containers like hash tables, maps, sets, etc. • 5. Pointer Support C++ also supports pointers which are often not available in other programming languages. • 6. Closer to Hardware C++ is closer to hardware than most general-purpose programming languages. This makes it very useful in those areas where hardware and software are closely coupled together, and low-level support is needed at the software level. Developer has more control over hardware aspects, like memory management and CPU usage.
  • 21. Features of C++ 1) Simple C++ is a simple language because it provides a structured approach (to break the problem into parts), a rich set of library functions, data types, etc. 2) Abstract Data types In C++, complex data types called Abstract Data Types (ADT) can be created using classes. 3) Portable • C++ is a portable language and programs made in it can be run on different machines.
  • 22. Features of C++ 4) Mid-level / Intermediate programming language C++ includes both low-level programming and high-level language so it is known as a mid-level and intermediate programming language. It is used to develop system applications such as kernel, driver, etc. 5) Structured programming language C++ is a structured programming language. In this we can divide the program into several parts using functions. 6) Rich Library C++ provides a lot of inbuilt functions that make the development fast. Following are the libraries used in C++ programming are: • <iostream> • <cmath> • <cstdlib> • <fstream>
  • 23. Features of C++ 7) Memory Management • C++ provides very efficient management techniques. The various memory management operators help save the memory and improve the program's efficiency. These operators allocate and deallocate memory at run time. Some common memory management operators available C++ are new, delete etc. 8) Quicker Compilation • C++ programs tend to be compact and run quickly. Hence the compilation and execution time of the C++ language is fast. 9) Pointer • C++ provides the feature of pointers. We can use pointers for memory, structures, functions, array, etc. We can directly interact with the memory by using the pointers. 10) Recursion • In C++, we can call the function within the function. It provides code reusability for every function.
  • 24. Features of C++ 11) Extensible • C++ programs can easily be extended as it is very easy to add new features into the existing program. 12) Object-Oriented • In C++, object-oriented concepts like data hiding, encapsulation, and data abstraction can easily be implemented using keyword class, private, public, and protected access specifiers. Object-oriented makes development and maintenance easier. 13) Compiler based • C++ is a compiler-based programming language, which means no C++ program can be executed without compilation. C++ compiler is easily available, and it requires very little space for storage. First, we need to compile our program using a compiler, and then we can execute our program.
  • 25. Features of C++ 14) Reusability • With the use of inheritance of functions programs written in C++ can be reused in any other program of C++. You can save program parts into library files and invoke them in your next programming projects simply by including the library files. New programs can be developed in lesser time as the existing code can be reused. It is also possible to define several functions with same name that perform different task. For Example: abs () is used to calculate the absolute value of integer, float and long integer. • 15) Redefine Existing Operators • C++ allows the programmer to redefine the meaning of existing operators such as +, -. For Example, The "+" operator can be used for adding two numbers and concatenating two strings.
  • 26. Features of C++ 16)National Standards • C++ has national standards such as ANSI. (American National Standards Institute) 17) Errors are easily detected • It is easier to maintain a C++ programs as errors can be easily located and rectified. It also provides a feature called exception handling to support error handling in your program. 18) Clarity • The keywords and library functions used in C++ resemble common English words.
  • 27. Features of C++ 19) Power and Flexibility • C++ is a powerful and flexible language because of most of the powerful flexible and modern UNIX operating system is written in C++. Many compilers and interpreters for other languages such as FORTRAN, PERL, Python, PASCAL, BASIC, LISP, etc., have been written in C++. C++ programs have been used for solving physics and engineering problems and even for animated special effects for movies. 20) Modelling real-world problems • The programs written in C++ are well suited for real-world modeling problems as close as possible to the user perspective.
  • 28. Differences between C and C++: • Definition C is a structural programming language, and it does not support classes and objects, while C++ is an object-oriented programming language that supports the concept of classes and objects. • Type of programming language C is procedure oriented programming language(POP) , while C++ is an object- oriented programming language(OOP). • Subset C++ is a superset of C programming language. C++ can run 99% of C code but C language cannot run C++ code. • Type of approach C follows the top-down approach, while C++ follows the bottom-up approach. The top-down approach breaks the main modules into tasks; these tasks are broken into sub-tasks, and so on. The bottom-up approach develops the lower level modules first and then the next level modules.
  • 29. Differences between C and C++: • Keywords C contains 32 keywords, and C++ supports 63 keywords.(81 as of C++20) • Security In C, the data can be easily manipulated by the outsiders as it does not support the encapsulation and information hiding while C++ is a very secure language, i.e., no outsiders can manipulate its data as it supports both encapsulation and data hiding. In C language, functions and data are the free entities, and in C++ language, all the functions and data are encapsulated in the form of objects. • Exception handling C does not provide direct support to the exception handling; it needs to use functions that support exception handling. C++ provides direct support to exception handling by using a try-catch block. • Input/Output functions In C, scanf and printf functions are used for input and output operations, respectively, while in C++, cin and cout are used for input and output operations, respectively.
  • 30. Differences between C and C++: • Memory allocation and de-allocation C supports calloc() and malloc() functions for the memory allocation, and free() function for the memory de-allocation. C++ supports a new operator for the memory allocation and delete operator for the memory de-allocation. • Header file C program uses <stdio.h> header file while C++ program uses <iostream.h> header file. • Namespace feature A namespace is a feature that groups the entities like classes, objects, and functions under some specific name. C does not contain the namespace feature, while C++ supports the namespace feature that avoids the name collisions.
  • 31. Writing and executing a C++ Program Step1. Creating source code Using Vi Editor : • Open terminal • write command vi filename.cpp” for C++ (“vi filename.c” For C) • Enter “I” , to activate insert mode in vi editor . • Write your code • Enter “Esc” • Enter “:” • write “wq” ,Enter. • Now source file is created with .cpp extention
  • 32. • Step 2: • Compiling the source code: • The source file has to be converted into machine code using a compiler. For this we can use Turbo C++ or GNU C++ Compiler • Using GNU C++ Compiler gcc or g++: • for cpp code write “g++ - o filename filename.cpp” , Or write “g++ filename.cpp” • (for c code write “gcc - o filename filename.c” ,Enter) • After compiling a runnable file will be created which is called object file .(with extention .o/.obj)
  • 33. • Step3: • Linking the object code to create an Executable code- • After compilation the object file is given to linker. • This program combines the files, add necessary libraries and creates an executable file with extension .exe • Step4 • Executing the Program • Once the executable file is created, you can run it by typing its name at the DOS command prompt or through the option provided by the compiler software. • In linux /centos you can write ./filename or ./a.out and press enter.
  • 37. Simple C++ Program • #include <iostream> is Directives for preprocessor: • A namespace is a feature that groups the entities like classes, objects, and functions under some specific name. • As the same name can’t be given to multiple variables, functions, classes, etc. in the same scope. • So to overcome this situation namespace is introduced. • namespace defines a scope of that entity. • std is a namespace whose members are used in the program the members of the “std” namespace are cout, cin, endl, etc. • int main() : It is Function Signatures
  • 38. #include <iostream> using namespace std; namespace sybca // first name space { void show_topper() { cout << "Raj is topper"<< endl; } } // second name space namespace tybca { void show_topper() { cout << "Radha is topper"<< endl; } } using namespace sybca; int main () { show_topper(); return 0; } •What is output ?? •Rewrite same program without using namespace
  • 39. Directives: #include <iostream> • In the first line, the file iostream is included into the current .cpp file. The hashtag (#) signals to a program called the preprocessor which reads through your source code, looking for all the lines that begin the with # symbol. The command #include tells the preprocessor “find the file iostream, read it, and place it here.” The angle brackets (<>) surrounding the file name tells the preprocessor to look in the usual places for this file. If your compiler is set up properly, all the include files are in one repository. • The file iostream is used by cout, which writes to the console. The effect of #include <iostream> is to include the file iostream into this C++ program as if you typed it in yourself.
  • 40. Function Signatures: int main() • The actual program begins with the function main(). Every C++ program needs to have a main() function because when you execute your program, main() is called automatically. • A function’s signature is important because it defines the inputs and outputs of the function. In int main(), the first part int states that the main() function returns an interger value to the operating system. This function achieves that because, at the bottom, it executes return 0. • Note: The compiler will allow you to return other data types. However, for main(), the only legal return type is int. Generally, it is the informal convention to return 0 to express that the program has ended without errors.
  • 41. The Function Body & Namespaces • All functions begin with an opening brace ({) and end with a closing brace (}). Everything in between the braces is considered to be part of that function. • cout and cin are used in C++ to handle input (such as user input from a keyboard) and output (such as printing to the console). • cout and cin objects provided by the standard library (std) • The standard library is the standard collection of objects that comes with every C++ compiler. • By using the namespace specifier std, You tell the compiler that the cout object you can use is part of the standard library
  • 42. Assignment 1 • Q1. Explain features of C++ language? • Q2.What are advantages of C++ ? • Q3. What is Procedure Oriented Programming? • Q4. What is object Oriented Programming? • Q5. Write advantages and limitations of object oriented programming.