SlideShare a Scribd company logo
1
CSE 459.22
Programming in C++
2
Overview
โ€ข Sign roster list
โ€ข Syllabus and Course Policies
โ€ข Introduction to C++
โ€ข About Lab 1
โ€ข Fill Questionnaire
3
Introduction to C++
โ€ข Programming Concept
โ€ข Basic C++
โ€ข C++ Extension from C
4
Focus
โ€ข Focus on
โ€“ Programming Concepts
โ€“ Programming Design Techniques
โ€ข Donโ€™t get lost in
โ€“ Language Technical Details
5
What is programming?
Programming is taking
A problem
Find the area of a rectangle
A set of data
length
width
A set of functions
area = length * width
Then,
Applying functions to data to solve the problem
6
Programming Concept Evolution
โ€ข Unstructured
โ€ข Procedural
โ€ข Object-Oriented
7
Procedural Concept
โ€ข The main program coordinates calls to
procedures and hands over appropriate data
as parameters.
8
Procedural Concept (II)
โ€ข Procedural Languages
โ€“ C, Pascal, Basic, Fortran
โ€“ Facilities to
โ€ข Pass arguments to functions
โ€ข Return values from functions
โ€ข For the rectangle problem, we develop a
function
int compute_area (int l, int w){
return ( l * w );
}
9
Object-Oriented Concept
โ€ข Objects of the program interact by sending messages to
each other
10
Objects
An object is an encapsulation of both functions and data
โ€ข Objects are an Abstraction
โ€“ represent real world entities
โ€“ Classes are data types that define shared common properties or attributes
โ€“ Objects are instances of a class
โ€ข Objects have State
โ€“ have a value at a particular time
โ€ข Objects have Operations
โ€“ associated set of operations called methods that describe how to carry out
operations
โ€ข Objects have Messages
โ€“ request an object to carry out one of its operations by sending it a message
โ€“ messages are the means by which we exchange data between objects
11
OO Perspective
Let's look at the Rectangle through object oriented eyes:
โ€ข Define a new type Rectangle (a class)
โ€“ Data
โ€ข width, length
โ€“ Function
โ€ข area()
โ€ข Create an instance of the class (an object)
โ€ข Request the object for its area
In C++, rather than writing a procedure, we define a
class that encapsulates the knowledge necessary to
answer the question - here, what is the area of the
rectangle.
12
class Rectangle
{
private:
int width, length;
public:
Rectangle(int w, int l)
{
width = w;
length = l;
}
main()
{
Rectangle rect(3, 5);
cout << rect.area()<<endl;
}
int area()
{
return width*length;
}
};
Example Object Oriented Code
13
Object-Oriented Programming
Languages
โ€ข Characteristics of OOPL:
โ€“ Encapsulation
โ€“ Inheritance
โ€“ Polymorphism
โ€ข OOPLs support :
โ€“ Modular Programming
โ€“ Ease of Development
โ€“ Maintainability
14
Characteristics of OOPL
โ€ข Encapsulation: Combining data structure with actions
โ€“ Data structure: represents the properties, the state, or characteristics of objects
โ€“ Actions: permissible behaviors that are controlled through the member functions
Data hiding: Process of making certain data inaccessible
โ€ข Inheritance: Ability to derive new objects from old ones
โ€“ permits objects of a more specific class to inherit the properties (data) and
behaviors (functions) of a more general/base class
โ€“ ability to define a hierarchical relationship between objects
โ€ข Polymorphism: Ability for different objects to interpret
functions differently
15
Basic C++
โ€ข Inherit all ANSI C directives
โ€ข Inherit all C functions
โ€ข You donโ€™t have to write OOP programming
in C++
16
Basic C++ Extension from C
โ€ข comments
/* You can still use the old comment style, */
/* but you must be // very careful about mixing them */
// It's best to use this style for 1 line or partial lines
/* And use this style when your comment
consists of multiple lines */
โ€ข cin and cout (and #include <iostream.h>)
cout << "hey";
char name[10];
cin >> name;
cout << "Hey " << name << ", nice name." << endl;
cout << endl; // print a blank line
โ€ข declaring variables almost anywhere
// declare a variable when you need it
for (int k = 1; k < 5; k++){
cout << k;
}
17
Basic C++ Extension from C (II)
โ€ข const
โ€“ In C, #define statement
โ€ข Preprocessor - No type checking.
โ€ข #define n 5
โ€“ In C++, the const specifier
โ€ข Compiler - Type checking is applied
โ€ข const int n = 5; // declare and initialize
โ€ข New data type
โ€“ Reference data type โ€œ&โ€.
int ix; /* ix is "real" variable */
int & rx = ix; /* rx is โ€œaliasโ€ for ix. Must initialize*/
ix = 1; /* also rx == 1 */
rx = 2; /* also ix == 2 */
18
C++ - Advance Extension
โ€ข C++ allows function overloading
โ€“ In C++, functions can use the same names, within
the same scope, if each can be distinguished by its
name and signature
โ€“ The signature specifies the number, type, and order
of the parameters expressed as a comma separated
list of argument types
19
C++
โ€ข Is a better C
โ€ข Expressive
โ€ข Supports Data Abstraction
โ€ข Supports OOP
โ€ข Supports Generic Programming
โ€“ Containers
โ€ข Stack of char, int, double etc
โ€“ Generic Algorithms
โ€ข sort(), copy(), search() any container Stack/Vector/List
20
Take Home Message
โ€ข There are many different kinds of programming
paradigms, OOP is one among them.
โ€ข In OOP, programmers see the execution of the
program as a collection of dialoging objects.
โ€ข The main characteristics of OOPL include
encapsulation, inheritance, and polymorphism.

More Related Content

Similar to Fundamentals of Programming in C++.ppt

Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
Tharindu Weerasinghe
ย 
Objective-C for iOS Application Development
Objective-C for iOS Application DevelopmentObjective-C for iOS Application Development
Objective-C for iOS Application Development
Dhaval Kaneria
ย 
L6
L6L6
L6
lksoo
ย 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
ย 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
FarazKhan89093
ย 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and Learn
Paul Irwin
ย 
OOP PPT 1.pptx
OOP PPT 1.pptxOOP PPT 1.pptx
OOP PPT 1.pptx
lathass5
ย 
Intro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the suIntro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the su
ImranAliQureshi3
ย 
Lecture02
Lecture02Lecture02
Lecture02
elearning_portal
ย 
Nitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptxNitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptx
shivam460694
ย 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
vinu28455
ย 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
marklaloo
ย 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
MZGINBarwary
ย 
Object Oriented Programming using C++ - OOPS concepts using C++ programming l...
Object Oriented Programming using C++ - OOPS concepts using C++ programming l...Object Oriented Programming using C++ - OOPS concepts using C++ programming l...
Object Oriented Programming using C++ - OOPS concepts using C++ programming l...
PreethaV16
ย 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
Sangharsh agarwal
ย 
C# 7 development
C# 7 developmentC# 7 development
C# 7 development
Fisnik Doko
ย 
C cpluplus 2
C cpluplus 2C cpluplus 2
C cpluplus 2
sanya6900
ย 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
ย 
C++ Programming
C++ ProgrammingC++ Programming

Similar to Fundamentals of Programming in C++.ppt (20)

Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
ย 
Objective-C for iOS Application Development
Objective-C for iOS Application DevelopmentObjective-C for iOS Application Development
Objective-C for iOS Application Development
ย 
L6
L6L6
L6
ย 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
ย 
c++ ppt.ppt
c++ ppt.pptc++ ppt.ppt
c++ ppt.ppt
ย 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
ย 
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and Learn
ย 
OOP PPT 1.pptx
OOP PPT 1.pptxOOP PPT 1.pptx
OOP PPT 1.pptx
ย 
Intro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the suIntro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the su
ย 
Lecture02
Lecture02Lecture02
Lecture02
ย 
Nitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptxNitin Mishra 0301EC201039 Internship PPT.pptx
Nitin Mishra 0301EC201039 Internship PPT.pptx
ย 
UsingCPP_for_Artist.ppt
UsingCPP_for_Artist.pptUsingCPP_for_Artist.ppt
UsingCPP_for_Artist.ppt
ย 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
ย 
lecture02-cpp.ppt
lecture02-cpp.pptlecture02-cpp.ppt
lecture02-cpp.ppt
ย 
Object Oriented Programming using C++ - OOPS concepts using C++ programming l...
Object Oriented Programming using C++ - OOPS concepts using C++ programming l...Object Oriented Programming using C++ - OOPS concepts using C++ programming l...
Object Oriented Programming using C++ - OOPS concepts using C++ programming l...
ย 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
ย 
C# 7 development
C# 7 developmentC# 7 development
C# 7 development
ย 
C cpluplus 2
C cpluplus 2C cpluplus 2
C cpluplus 2
ย 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
ย 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
ย 

Recently uploaded

Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
ย 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
ย 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
ย 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
ย 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
ย 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
ย 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
ย 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
ย 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
ย 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
ย 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
ย 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
ย 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
ย 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
ย 
Bossa Nโ€™ Roll Records by Ismael Vazquez.
Bossa Nโ€™ Roll Records by Ismael Vazquez.Bossa Nโ€™ Roll Records by Ismael Vazquez.
Bossa Nโ€™ Roll Records by Ismael Vazquez.
IsmaelVazquez38
ย 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
ย 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
ย 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
ย 

Recently uploaded (20)

Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
ย 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
ย 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
ย 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
ย 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
ย 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
ย 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
ย 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
ย 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
ย 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
ย 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
ย 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
ย 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
ย 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
ย 
Bossa Nโ€™ Roll Records by Ismael Vazquez.
Bossa Nโ€™ Roll Records by Ismael Vazquez.Bossa Nโ€™ Roll Records by Ismael Vazquez.
Bossa Nโ€™ Roll Records by Ismael Vazquez.
ย 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
ย 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
ย 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
ย 

Fundamentals of Programming in C++.ppt

  • 2. 2 Overview โ€ข Sign roster list โ€ข Syllabus and Course Policies โ€ข Introduction to C++ โ€ข About Lab 1 โ€ข Fill Questionnaire
  • 3. 3 Introduction to C++ โ€ข Programming Concept โ€ข Basic C++ โ€ข C++ Extension from C
  • 4. 4 Focus โ€ข Focus on โ€“ Programming Concepts โ€“ Programming Design Techniques โ€ข Donโ€™t get lost in โ€“ Language Technical Details
  • 5. 5 What is programming? Programming is taking A problem Find the area of a rectangle A set of data length width A set of functions area = length * width Then, Applying functions to data to solve the problem
  • 6. 6 Programming Concept Evolution โ€ข Unstructured โ€ข Procedural โ€ข Object-Oriented
  • 7. 7 Procedural Concept โ€ข The main program coordinates calls to procedures and hands over appropriate data as parameters.
  • 8. 8 Procedural Concept (II) โ€ข Procedural Languages โ€“ C, Pascal, Basic, Fortran โ€“ Facilities to โ€ข Pass arguments to functions โ€ข Return values from functions โ€ข For the rectangle problem, we develop a function int compute_area (int l, int w){ return ( l * w ); }
  • 9. 9 Object-Oriented Concept โ€ข Objects of the program interact by sending messages to each other
  • 10. 10 Objects An object is an encapsulation of both functions and data โ€ข Objects are an Abstraction โ€“ represent real world entities โ€“ Classes are data types that define shared common properties or attributes โ€“ Objects are instances of a class โ€ข Objects have State โ€“ have a value at a particular time โ€ข Objects have Operations โ€“ associated set of operations called methods that describe how to carry out operations โ€ข Objects have Messages โ€“ request an object to carry out one of its operations by sending it a message โ€“ messages are the means by which we exchange data between objects
  • 11. 11 OO Perspective Let's look at the Rectangle through object oriented eyes: โ€ข Define a new type Rectangle (a class) โ€“ Data โ€ข width, length โ€“ Function โ€ข area() โ€ข Create an instance of the class (an object) โ€ข Request the object for its area In C++, rather than writing a procedure, we define a class that encapsulates the knowledge necessary to answer the question - here, what is the area of the rectangle.
  • 12. 12 class Rectangle { private: int width, length; public: Rectangle(int w, int l) { width = w; length = l; } main() { Rectangle rect(3, 5); cout << rect.area()<<endl; } int area() { return width*length; } }; Example Object Oriented Code
  • 13. 13 Object-Oriented Programming Languages โ€ข Characteristics of OOPL: โ€“ Encapsulation โ€“ Inheritance โ€“ Polymorphism โ€ข OOPLs support : โ€“ Modular Programming โ€“ Ease of Development โ€“ Maintainability
  • 14. 14 Characteristics of OOPL โ€ข Encapsulation: Combining data structure with actions โ€“ Data structure: represents the properties, the state, or characteristics of objects โ€“ Actions: permissible behaviors that are controlled through the member functions Data hiding: Process of making certain data inaccessible โ€ข Inheritance: Ability to derive new objects from old ones โ€“ permits objects of a more specific class to inherit the properties (data) and behaviors (functions) of a more general/base class โ€“ ability to define a hierarchical relationship between objects โ€ข Polymorphism: Ability for different objects to interpret functions differently
  • 15. 15 Basic C++ โ€ข Inherit all ANSI C directives โ€ข Inherit all C functions โ€ข You donโ€™t have to write OOP programming in C++
  • 16. 16 Basic C++ Extension from C โ€ข comments /* You can still use the old comment style, */ /* but you must be // very careful about mixing them */ // It's best to use this style for 1 line or partial lines /* And use this style when your comment consists of multiple lines */ โ€ข cin and cout (and #include <iostream.h>) cout << "hey"; char name[10]; cin >> name; cout << "Hey " << name << ", nice name." << endl; cout << endl; // print a blank line โ€ข declaring variables almost anywhere // declare a variable when you need it for (int k = 1; k < 5; k++){ cout << k; }
  • 17. 17 Basic C++ Extension from C (II) โ€ข const โ€“ In C, #define statement โ€ข Preprocessor - No type checking. โ€ข #define n 5 โ€“ In C++, the const specifier โ€ข Compiler - Type checking is applied โ€ข const int n = 5; // declare and initialize โ€ข New data type โ€“ Reference data type โ€œ&โ€. int ix; /* ix is "real" variable */ int & rx = ix; /* rx is โ€œaliasโ€ for ix. Must initialize*/ ix = 1; /* also rx == 1 */ rx = 2; /* also ix == 2 */
  • 18. 18 C++ - Advance Extension โ€ข C++ allows function overloading โ€“ In C++, functions can use the same names, within the same scope, if each can be distinguished by its name and signature โ€“ The signature specifies the number, type, and order of the parameters expressed as a comma separated list of argument types
  • 19. 19 C++ โ€ข Is a better C โ€ข Expressive โ€ข Supports Data Abstraction โ€ข Supports OOP โ€ข Supports Generic Programming โ€“ Containers โ€ข Stack of char, int, double etc โ€“ Generic Algorithms โ€ข sort(), copy(), search() any container Stack/Vector/List
  • 20. 20 Take Home Message โ€ข There are many different kinds of programming paradigms, OOP is one among them. โ€ข In OOP, programmers see the execution of the program as a collection of dialoging objects. โ€ข The main characteristics of OOPL include encapsulation, inheritance, and polymorphism.