SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
Prepared by
Mohammed Sikander
Technical Lead
CranesVarsity
 This presentation consists of set of questions
which on solving and reasoning will help you
to understand the concepts clearly.
 Topics include
 Pointers
 References
 FunctionOverloading
 Default arguments
Mohammed Sikander 2
void update(int *ptr)
{
*ptr++;
}
int main( )
{
int a = 5;
update(&a);
cout << a << endl;
}
Mohammed Sikander 3
void myswap(int *pa , int *pb)
{
int *temp = pa;
pa = pb;
pb = temp;
printf("MySwap *pa = %d *pb = %d n",*pa , *pb);
}
int main( )
{
int a = 5 , b = 10;
myswap(&a , &b);
printf("Main a = %d b = %d n",a , b);
}
Mohammed Sikander 4
Mohammed Sikander 5
Write the Output
void fun(int *ptr)
{
int b = 10;
ptr = &b;
printf(“Fun %d n”,*ptr);
}
int main()
{
int a = 5;
int *ptr = &a;
fun(ptr);
printf(“Main %d n“ , *ptr);
}
Mohammed Sikander 6
Write the Output
void fun(int ref)
{
ref++;
cout<<"Fun ref= "<<ref<<endl;
}
int main()
{
int a = 5;
int &ref = a;
fun(ref);
cout<<"Main ref= "<<ref<<endl;
}
int main()
{
int a = 4;
const int b = 3;
1. int *ptr1 = &a;
2. int *ptr2 = &b;
3. int * const ptr3 = &b;
4. const int * ptr4 = &b;
5. int * const ptr5 = &a;
6. const int * ptr6 = &a;
return 0;
}
Mohammed Sikander 7
int main()
{
int a = 4;
const int b = 3;
1. int &ref1 = a;
2. int &ref2 = b;
3. const int &ref3 = a;
4. const int &ref4 = b;
return 0;
}
Mohammed Sikander 8
int main( )
{
int a = 5 , b = 10 ;
int c = a + b;
int *ptr1 = &a + b;
int *ptr2 = &(a + b);
}
Mohammed Sikander 9
int main( )
{
int a = 5 , b = 10 ;
int &r1 = a + b;
int &r2 = 5;
}
Identify the valid and invalid statements.
void func(int &a)
{
}
int main( )
{
int a = 5, b = 10;
int c;
1. func(a);
2. func(c);
3. func(a + b);
4. func(5);
}
Mohammed Sikander 10
Identify the valid and invalid statements.
void func(const int &a)
{
}
int main( )
{
int a = 5, b = 10;
int c;
func(a); //statement 1
func(c); //statement 2
func(a + b); //statement 3
func(5); //statement 4
}
Mohammed Sikander 11
Can we overload these two functions
void func(int *p)
{
}
void func(int p)
{
}
int main()
{
}
Mohammed Sikander 12
Can we overload these two functions
void func(int &a)
{
}
void func(int a)
{
}
int main()
{
}
Mohammed Sikander 13
Can we overload these two functions
void func(int &a)
{
}
void func(const int &a)
{
}
int main()
{
}
Mohammed Sikander 14
Can we overload these two functions
char func( )
{
return 'a';
}
double func()
{
return 10.5;
}
int main()
{
char c = func();
double d = func();
}
Mohammed Sikander 15
What is the output
void func(char a)
{
cout <<"Character " << a << endl;
}
int main()
{
func('A');
func('A' + ' '); //A + space
}
Mohammed Sikander 16
void func(char a)
{
cout <<"Character " << a << endl;
}
void func(int a)
{
cout <<"Integer " << a << endl;
}
int main()
{
func('A'); //Statement 1
func('A' + ' '); //Statement 2
}
Mohammed Sikander 17
int add(int a = 5 , int b = 10);
int main( )
{
cout << add( 2 , 6) << endl;
cout << add( 2 ) << endl;
cout << add( ) << endl;
}
int add(int a = 5 , int b = 10)
{
return a + b;
}
Mohammed Sikander 18
Identify the valid and invalid Declarations
void func1(int a = 5 , int b = 10 ,int c = 20);
void func2(int a ,int b ,int c = 20);
void func3(int a = 5 ,int b ,int c );
void func4(int a = 5 ,int b = 10 ,int c );
Mohammed Sikander 19
void add(int a , int b = 5)
{
cout << “Add with 2 parameter”;
}
void add(int x)
{
cout <<“Add with 1 parameter”;
}
int main( )
{
add(5);
}
Mohammed Sikander 20
What is the header file to be included if you
want to use malloc and free?
What is the header file to be included if you
want to use new and delete?
Name some memory leakage detection tools?
Mohammed Sikander 21
int main( )
{
int *ptr = new int(5);
return 0;
}
Mohammed Sikander 22
int *ptr;
void func( )
{
ptr = new int[5];
}
int main( )
{
ptr = new int[5];
func( );
return 0;
}
int main( )
{
int *ptr = new int[5];
return 0;
}

Más contenido relacionado

La actualidad más candente (20)

C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
C++ file
C++ fileC++ file
C++ file
 
C questions
C questionsC questions
C questions
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
C++ programs
C++ programsC++ programs
C++ programs
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
Functions
FunctionsFunctions
Functions
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Double linked list
Double linked listDouble linked list
Double linked list
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
 
Arrays
ArraysArrays
Arrays
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
 

Destacado

Uni papua fc landak unit menjalin is doing an exercise routine
Uni papua fc landak unit menjalin is doing an exercise routineUni papua fc landak unit menjalin is doing an exercise routine
Uni papua fc landak unit menjalin is doing an exercise routineUni Papua Football
 
Location Based Development Using Xamarin
Location Based Development Using XamarinLocation Based Development Using Xamarin
Location Based Development Using XamarinKym Phillpotts
 
Option 1 Phase 4 of IT Infrastructure for a Small Firm
Option 1 Phase 4 of IT Infrastructure for a Small FirmOption 1 Phase 4 of IT Infrastructure for a Small Firm
Option 1 Phase 4 of IT Infrastructure for a Small FirmAdam Fisher
 
Visit saimaa tourism development 2015-2016
Visit saimaa tourism development 2015-2016Visit saimaa tourism development 2015-2016
Visit saimaa tourism development 2015-2016Matkailufoorumi
 
Makalah hpp akpe raha
Makalah hpp akpe rahaMakalah hpp akpe raha
Makalah hpp akpe rahaWarnet Raha
 
Priorities for 21st century family medicine research
Priorities for 21st century family medicine researchPriorities for 21st century family medicine research
Priorities for 21st century family medicine researchDonald Nease
 
c. Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...
c.	Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...c.	Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...
c. Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...Warnet Raha
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functionsmohamed sikander
 

Destacado (16)

Uni papua fc landak unit menjalin is doing an exercise routine
Uni papua fc landak unit menjalin is doing an exercise routineUni papua fc landak unit menjalin is doing an exercise routine
Uni papua fc landak unit menjalin is doing an exercise routine
 
Lecture6
Lecture6Lecture6
Lecture6
 
Growing a SQL Query
Growing a SQL QueryGrowing a SQL Query
Growing a SQL Query
 
Location Based Development Using Xamarin
Location Based Development Using XamarinLocation Based Development Using Xamarin
Location Based Development Using Xamarin
 
Option 1 Phase 4 of IT Infrastructure for a Small Firm
Option 1 Phase 4 of IT Infrastructure for a Small FirmOption 1 Phase 4 of IT Infrastructure for a Small Firm
Option 1 Phase 4 of IT Infrastructure for a Small Firm
 
Visit saimaa tourism development 2015-2016
Visit saimaa tourism development 2015-2016Visit saimaa tourism development 2015-2016
Visit saimaa tourism development 2015-2016
 
Tugas biokimia
Tugas biokimiaTugas biokimia
Tugas biokimia
 
Fin corp pro Brochure
Fin corp pro BrochureFin corp pro Brochure
Fin corp pro Brochure
 
Tik kls viii smstr 1 (bab 2)
Tik kls viii smstr 1 (bab 2)Tik kls viii smstr 1 (bab 2)
Tik kls viii smstr 1 (bab 2)
 
Makalah hpp akpe raha
Makalah hpp akpe rahaMakalah hpp akpe raha
Makalah hpp akpe raha
 
All you need to know about Statistics
All you need to know about StatisticsAll you need to know about Statistics
All you need to know about Statistics
 
Priorities for 21st century family medicine research
Priorities for 21st century family medicine researchPriorities for 21st century family medicine research
Priorities for 21st century family medicine research
 
Java strings
Java   stringsJava   strings
Java strings
 
c. Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...
c.	Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...c.	Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...
c. Merumuskan diagnosa/masalah potensial pada Bayi Ny “N” dengan BBLR di Ruan...
 
Lowe lintas
Lowe lintasLowe lintas
Lowe lintas
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functions
 

Similar a C++ pointers, references, functions concepts explained

2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
Cs1123 8 functions
Cs1123 8 functionsCs1123 8 functions
Cs1123 8 functionsTAlha MAlik
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation19magnet
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKGuardSquare
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 
Lec 38.39 - pointers
Lec 38.39 -  pointersLec 38.39 -  pointers
Lec 38.39 - pointersPrincess Sam
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxssuser3cbb4c
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKGuardSquare
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceranaibrahim453
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 

Similar a C++ pointers, references, functions concepts explained (20)

2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Cs1123 8 functions
Cs1123 8 functionsCs1123 8 functions
Cs1123 8 functions
 
Quiz 10 cp_sol
Quiz 10 cp_solQuiz 10 cp_sol
Quiz 10 cp_sol
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
 
C++ Programm.pptx
C++ Programm.pptxC++ Programm.pptx
C++ Programm.pptx
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
pointers 1
pointers 1pointers 1
pointers 1
 
Lec 38.39 - pointers
Lec 38.39 -  pointersLec 38.39 -  pointers
Lec 38.39 - pointers
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
 
C++ L05-Functions
C++ L05-FunctionsC++ L05-Functions
C++ L05-Functions
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
Functions
FunctionsFunctions
Functions
 
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDKEric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
Eric Lafortune - ProGuard: Optimizer and obfuscator in the Android SDK
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practice
 
Pointer basics
Pointer basicsPointer basics
Pointer basics
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 

Más de mohamed sikander

Más de mohamed sikander (6)

C++ 11 range-based for loop
C++ 11   range-based for loopC++ 11   range-based for loop
C++ 11 range-based for loop
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Cquestions
Cquestions Cquestions
Cquestions
 
Container adapters
Container adaptersContainer adapters
Container adapters
 

Último

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 

Último (20)

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 

C++ pointers, references, functions concepts explained

  • 2.  This presentation consists of set of questions which on solving and reasoning will help you to understand the concepts clearly.  Topics include  Pointers  References  FunctionOverloading  Default arguments Mohammed Sikander 2
  • 3. void update(int *ptr) { *ptr++; } int main( ) { int a = 5; update(&a); cout << a << endl; } Mohammed Sikander 3
  • 4. void myswap(int *pa , int *pb) { int *temp = pa; pa = pb; pb = temp; printf("MySwap *pa = %d *pb = %d n",*pa , *pb); } int main( ) { int a = 5 , b = 10; myswap(&a , &b); printf("Main a = %d b = %d n",a , b); } Mohammed Sikander 4
  • 5. Mohammed Sikander 5 Write the Output void fun(int *ptr) { int b = 10; ptr = &b; printf(“Fun %d n”,*ptr); } int main() { int a = 5; int *ptr = &a; fun(ptr); printf(“Main %d n“ , *ptr); }
  • 6. Mohammed Sikander 6 Write the Output void fun(int ref) { ref++; cout<<"Fun ref= "<<ref<<endl; } int main() { int a = 5; int &ref = a; fun(ref); cout<<"Main ref= "<<ref<<endl; }
  • 7. int main() { int a = 4; const int b = 3; 1. int *ptr1 = &a; 2. int *ptr2 = &b; 3. int * const ptr3 = &b; 4. const int * ptr4 = &b; 5. int * const ptr5 = &a; 6. const int * ptr6 = &a; return 0; } Mohammed Sikander 7
  • 8. int main() { int a = 4; const int b = 3; 1. int &ref1 = a; 2. int &ref2 = b; 3. const int &ref3 = a; 4. const int &ref4 = b; return 0; } Mohammed Sikander 8
  • 9. int main( ) { int a = 5 , b = 10 ; int c = a + b; int *ptr1 = &a + b; int *ptr2 = &(a + b); } Mohammed Sikander 9 int main( ) { int a = 5 , b = 10 ; int &r1 = a + b; int &r2 = 5; }
  • 10. Identify the valid and invalid statements. void func(int &a) { } int main( ) { int a = 5, b = 10; int c; 1. func(a); 2. func(c); 3. func(a + b); 4. func(5); } Mohammed Sikander 10
  • 11. Identify the valid and invalid statements. void func(const int &a) { } int main( ) { int a = 5, b = 10; int c; func(a); //statement 1 func(c); //statement 2 func(a + b); //statement 3 func(5); //statement 4 } Mohammed Sikander 11
  • 12. Can we overload these two functions void func(int *p) { } void func(int p) { } int main() { } Mohammed Sikander 12
  • 13. Can we overload these two functions void func(int &a) { } void func(int a) { } int main() { } Mohammed Sikander 13
  • 14. Can we overload these two functions void func(int &a) { } void func(const int &a) { } int main() { } Mohammed Sikander 14
  • 15. Can we overload these two functions char func( ) { return 'a'; } double func() { return 10.5; } int main() { char c = func(); double d = func(); } Mohammed Sikander 15
  • 16. What is the output void func(char a) { cout <<"Character " << a << endl; } int main() { func('A'); func('A' + ' '); //A + space } Mohammed Sikander 16
  • 17. void func(char a) { cout <<"Character " << a << endl; } void func(int a) { cout <<"Integer " << a << endl; } int main() { func('A'); //Statement 1 func('A' + ' '); //Statement 2 } Mohammed Sikander 17
  • 18. int add(int a = 5 , int b = 10); int main( ) { cout << add( 2 , 6) << endl; cout << add( 2 ) << endl; cout << add( ) << endl; } int add(int a = 5 , int b = 10) { return a + b; } Mohammed Sikander 18
  • 19. Identify the valid and invalid Declarations void func1(int a = 5 , int b = 10 ,int c = 20); void func2(int a ,int b ,int c = 20); void func3(int a = 5 ,int b ,int c ); void func4(int a = 5 ,int b = 10 ,int c ); Mohammed Sikander 19
  • 20. void add(int a , int b = 5) { cout << “Add with 2 parameter”; } void add(int x) { cout <<“Add with 1 parameter”; } int main( ) { add(5); } Mohammed Sikander 20
  • 21. What is the header file to be included if you want to use malloc and free? What is the header file to be included if you want to use new and delete? Name some memory leakage detection tools? Mohammed Sikander 21
  • 22. int main( ) { int *ptr = new int(5); return 0; } Mohammed Sikander 22 int *ptr; void func( ) { ptr = new int[5]; } int main( ) { ptr = new int[5]; func( ); return 0; } int main( ) { int *ptr = new int[5]; return 0; }