SlideShare a Scribd company logo
1 of 3
Download to read offline
DEFAULT ARGUMETNS Lecture 2.2
Prepared by: Mian Saeed Akbar
Default Arguments
Function call with omitted parameters
 If not enough parameters, rightmost go to their defaults
 Default values
 Can be constants, global variables, or function calls
Set defaults in function prototype
x = 3, y and z get defaults (rightmost)
x = 3, y = 5 and z gets default
int myFunction( int x = 1, int y = 2, int z = 3 );
myFunction( 3 );
myFunction( 3, 5 );
Thank you
Please subscribe my channel for more videos
and courses

More Related Content

More from MianSaeedAkbar1

More from MianSaeedAkbar1 (12)

Lecture 1.5 Variables.pdf
Lecture 1.5 Variables.pdfLecture 1.5 Variables.pdf
Lecture 1.5 Variables.pdf
 
Lecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdfLecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdf
 
Lecture 2.3 Inline Function.pdf
Lecture 2.3 Inline Function.pdfLecture 2.3 Inline Function.pdf
Lecture 2.3 Inline Function.pdf
 
Lecture 1.8 Conditional Structures.pdf
Lecture 1.8 Conditional Structures.pdfLecture 1.8 Conditional Structures.pdf
Lecture 1.8 Conditional Structures.pdf
 
Lecture 2.7 Type Conversion in C++.pdf
Lecture 2.7 Type Conversion in C++.pdfLecture 2.7 Type Conversion in C++.pdf
Lecture 2.7 Type Conversion in C++.pdf
 
Lecture 1.6 Arithmetic and Relational Operators.pdf
Lecture 1.6 Arithmetic and Relational Operators.pdfLecture 1.6 Arithmetic and Relational Operators.pdf
Lecture 1.6 Arithmetic and Relational Operators.pdf
 
Lecture 1.7 C++ Keywords.pdf
Lecture 1.7 C++ Keywords.pdfLecture 1.7 C++ Keywords.pdf
Lecture 1.7 C++ Keywords.pdf
 
Lecture 1.4 Escape Sequence.pdf
Lecture 1.4 Escape Sequence.pdfLecture 1.4 Escape Sequence.pdf
Lecture 1.4 Escape Sequence.pdf
 
Lecture 1.9 Switch Structure.pdf
Lecture 1.9 Switch Structure.pdfLecture 1.9 Switch Structure.pdf
Lecture 1.9 Switch Structure.pdf
 
Lecture 1.10 Repetition Structures.pdf
Lecture 1.10 Repetition Structures.pdfLecture 1.10 Repetition Structures.pdf
Lecture 1.10 Repetition Structures.pdf
 
Lecture 0 Object Oriented Programming.pdf
Lecture 0 Object Oriented Programming.pdfLecture 0 Object Oriented Programming.pdf
Lecture 0 Object Oriented Programming.pdf
 
Lecture 1.1 Introduction to Computer Languages.pdf
Lecture 1.1 Introduction to Computer Languages.pdfLecture 1.1 Introduction to Computer Languages.pdf
Lecture 1.1 Introduction to Computer Languages.pdf
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

Lecture 2.2 Default Arguments.pdf

  • 1. DEFAULT ARGUMETNS Lecture 2.2 Prepared by: Mian Saeed Akbar
  • 2. Default Arguments Function call with omitted parameters  If not enough parameters, rightmost go to their defaults  Default values  Can be constants, global variables, or function calls Set defaults in function prototype x = 3, y and z get defaults (rightmost) x = 3, y = 5 and z gets default int myFunction( int x = 1, int y = 2, int z = 3 ); myFunction( 3 ); myFunction( 3, 5 );
  • 3. Thank you Please subscribe my channel for more videos and courses