SlideShare a Scribd company logo
C++ Programming - 4th Study
C++ Programming - 4th Study
3
int main()
{
// int& ref;
int i = 10;
int& ref = i;
ref += 10;
std::cout << "i = " << i
<< std::endl;
std::cout << "ref = " << ref
<< std::endl;
return 0;
}
4
void swap(int* a, int* b)
{
int temp = *a; *a = *b; *b = temp;
}
int main()
{
int a = 10, b = 20;
std::cout << "a = " << a << ", b = " << b << std::endl;
swap(&a, &b);
std::cout << "a = " << a << ", b = " << b << std::endl;
return 0;
}
Pass-by-pointer
5
void swap(int& a, int& b)
{
int temp = a; a = b; b = temp;
}
int main()
{
int a = 10, b = 20;
std::cout << "a = " << a << ", b = " << b << std::endl;
swap(a, b);
std::cout << "a = " << a << ", b = " << b << std::endl;
return 0;
}
Pass-by-reference
6
C++ Programming - 4th Study
8
9
int computeRectArea1(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
return 0;
}
int computeRectArea2(int width, int height) {
return 0;
}
int main()
{
int area1 = computeRectArea1(1, 1, 1, 4, 3, 4, 3, 1);
int area2 = computeRectArea2(2, 3);
return 0;
}
C
10
int computeRectArea(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
return 0;
}
int computeRectArea(int width, int height) {
return 0;
}
int main()
{
int area1 = computeRectArea(1, 1, 1, 4, 3, 4, 3, 1);
int area2 = computeRectArea(2, 3);
return 0;
}
C++
11
C++ Programming - 4th Study
13
14
15
void print()
{
std::cout << "A's print" << std::endl;
}
void print()
{
std::cout << "B's print" << std::endl;
}
int main()
{
print();
return 0;
}
C
16
namespace A {
void print() { std::cout << "A's print()" << std::endl; }
}
namespace B {
void print() { std::cout << "B's print()" << std::endl; }
}
int main()
{
A::print();
B::print();
return 0;
}
C++
17
C++
18
C++
using namespace std;
namespace A {
void print() { cout << "A's print()" << endl; }
}
namespace B {
void print() { cout << "B's print()" << endl; }
}
int main()
{
A::print();
B::print();
}
19
namespace A { int i; }
namespace B { int i; }
using namespace A;
using namespace B;
int main()
{
// Don't do this
if (i == i) { }
if (A::i == B::i) { }
return 0;
}
20
Ad

Recommended

C++ Programming - 2nd Study
C++ Programming - 2nd Study
Chris Ohk
 
C++ Programming - 3rd Study
C++ Programming - 3rd Study
Chris Ohk
 
C++ Programming - 14th Study
C++ Programming - 14th Study
Chris Ohk
 
Data Structure - 2nd Study
Data Structure - 2nd Study
Chris Ohk
 
C++ Programming - 1st Study
C++ Programming - 1st Study
Chris Ohk
 
C++ Programming - 11th Study
C++ Programming - 11th Study
Chris Ohk
 
C++ programs
C++ programs
Mukund Gandrakota
 
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Stl algorithm-Basic types
Stl algorithm-Basic types
mohamed sikander
 
C++ TUTORIAL 8
C++ TUTORIAL 8
Farhan Ab Rahman
 
Implementing string
Implementing string
mohamed sikander
 
C++ TUTORIAL 5
C++ TUTORIAL 5
Farhan Ab Rahman
 
Implementing stack
Implementing stack
mohamed sikander
 
C++ file
C++ file
Mukund Trivedi
 
C++ Question on References and Function Overloading
C++ Question on References and Function Overloading
mohamed sikander
 
Operator overloading
Operator overloading
mohamed sikander
 
Static and const members
Static and const members
mohamed sikander
 
C++ TUTORIAL 2
C++ TUTORIAL 2
Farhan Ab Rahman
 
Inheritance and polymorphism
Inheritance and polymorphism
mohamed sikander
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Alex Penso Romero
 
Function basics
Function basics
mohamed sikander
 
C sharp 8
C sharp 8
Germán Küber
 
C++ TUTORIAL 1
C++ TUTORIAL 1
Farhan Ab Rahman
 
Understanding storage class using nm
Understanding storage class using nm
mohamed sikander
 
Oop1
Oop1
Vaibhav Bajaj
 
C++ TUTORIAL 3
C++ TUTORIAL 3
Farhan Ab Rahman
 
C questions
C questions
mohamed sikander
 
2013 C++ Study For Students #1
2013 C++ Study For Students #1
Chris Ohk
 
2014-15 Intermediate C++ Study #6
2014-15 Intermediate C++ Study #6
Chris Ohk
 

More Related Content

What's hot (20)

Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Stl algorithm-Basic types
Stl algorithm-Basic types
mohamed sikander
 
C++ TUTORIAL 8
C++ TUTORIAL 8
Farhan Ab Rahman
 
Implementing string
Implementing string
mohamed sikander
 
C++ TUTORIAL 5
C++ TUTORIAL 5
Farhan Ab Rahman
 
Implementing stack
Implementing stack
mohamed sikander
 
C++ file
C++ file
Mukund Trivedi
 
C++ Question on References and Function Overloading
C++ Question on References and Function Overloading
mohamed sikander
 
Operator overloading
Operator overloading
mohamed sikander
 
Static and const members
Static and const members
mohamed sikander
 
C++ TUTORIAL 2
C++ TUTORIAL 2
Farhan Ab Rahman
 
Inheritance and polymorphism
Inheritance and polymorphism
mohamed sikander
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Alex Penso Romero
 
Function basics
Function basics
mohamed sikander
 
C sharp 8
C sharp 8
Germán Küber
 
C++ TUTORIAL 1
C++ TUTORIAL 1
Farhan Ab Rahman
 
Understanding storage class using nm
Understanding storage class using nm
mohamed sikander
 
Oop1
Oop1
Vaibhav Bajaj
 
C++ TUTORIAL 3
C++ TUTORIAL 3
Farhan Ab Rahman
 
C questions
C questions
mohamed sikander
 

Viewers also liked (9)

2013 C++ Study For Students #1
2013 C++ Study For Students #1
Chris Ohk
 
2014-15 Intermediate C++ Study #6
2014-15 Intermediate C++ Study #6
Chris Ohk
 
2014-15 Intermediate C++ Study #7
2014-15 Intermediate C++ Study #7
Chris Ohk
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
Chris Ohk
 
NDC 2015 박주은,최재혁 물리기반렌더링 지난1년간의 경험
NDC 2015 박주은,최재혁 물리기반렌더링 지난1년간의 경험
Jooeun Park
 
Minimal standard c program
Minimal standard c program
Swain Loda
 
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
 
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
Chris Ohk
 
게임 프로그래밍 기초 공부법
게임 프로그래밍 기초 공부법
Chris Ohk
 
2013 C++ Study For Students #1
2013 C++ Study For Students #1
Chris Ohk
 
2014-15 Intermediate C++ Study #6
2014-15 Intermediate C++ Study #6
Chris Ohk
 
2014-15 Intermediate C++ Study #7
2014-15 Intermediate C++ Study #7
Chris Ohk
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
Chris Ohk
 
NDC 2015 박주은,최재혁 물리기반렌더링 지난1년간의 경험
NDC 2015 박주은,최재혁 물리기반렌더링 지난1년간의 경험
Jooeun Park
 
Minimal standard c program
Minimal standard c program
Swain Loda
 
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
 
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
Chris Ohk
 
게임 프로그래밍 기초 공부법
게임 프로그래밍 기초 공부법
Chris Ohk
 
Ad

Similar to C++ Programming - 4th Study (20)

C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
ssuser3cbb4c
 
Ch4
Ch4
aamirsahito
 
2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
CPP Language Basics - Reference
CPP Language Basics - Reference
Mohammed Sikander
 
Intro to c programming
Intro to c programming
Prabhu Govind
 
C++ file
C++ file
Mukund Trivedi
 
code (1) thông tin nhập môn cntt hdsd.docx
code (1) thông tin nhập môn cntt hdsd.docx
minhthucuteo2003
 
C++ normal assignments by maharshi_jd.pdf
C++ normal assignments by maharshi_jd.pdf
maharshi1731
 
C++ practical
C++ practical
Rahul juneja
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
oop Lecture 4
oop Lecture 4
Anwar Ul Haq
 
Arduino coding class
Arduino coding class
Jonah Marrs
 
Cpp c++ 1
Cpp c++ 1
Sltnalt Cosmology
 
C++ TUTORIAL 4
C++ TUTORIAL 4
Farhan Ab Rahman
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
premrings
 
how to reuse code
how to reuse code
jleed1
 
oodp elab.pdf
oodp elab.pdf
SWATIKUMARIRA2111030
 
Lab Question
Lab Question
Export Promotion Bureau
 
C++ file
C++ file
simarsimmygrewal
 
Assignement c++
Assignement c++
Syed Umair
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
ssuser3cbb4c
 
2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
CPP Language Basics - Reference
CPP Language Basics - Reference
Mohammed Sikander
 
Intro to c programming
Intro to c programming
Prabhu Govind
 
code (1) thông tin nhập môn cntt hdsd.docx
code (1) thông tin nhập môn cntt hdsd.docx
minhthucuteo2003
 
C++ normal assignments by maharshi_jd.pdf
C++ normal assignments by maharshi_jd.pdf
maharshi1731
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
Arduino coding class
Arduino coding class
Jonah Marrs
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
premrings
 
how to reuse code
how to reuse code
jleed1
 
Assignement c++
Assignement c++
Syed Umair
 
Ad

More from Chris Ohk (20)

인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
Chris Ohk
 
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
Chris Ohk
 
Momenti Seminar - 5 Years of RosettaStone
Momenti Seminar - 5 Years of RosettaStone
Chris Ohk
 
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
Chris Ohk
 
Momenti Seminar - A Tour of Rust, Part 2
Momenti Seminar - A Tour of Rust, Part 2
Chris Ohk
 
Momenti Seminar - A Tour of Rust, Part 1
Momenti Seminar - A Tour of Rust, Part 1
Chris Ohk
 
Evolving Reinforcement Learning Algorithms, JD. Co-Reyes et al, 2021
Evolving Reinforcement Learning Algorithms, JD. Co-Reyes et al, 2021
Chris Ohk
 
Adversarially Guided Actor-Critic, Y. Flet-Berliac et al, 2021
Adversarially Guided Actor-Critic, Y. Flet-Berliac et al, 2021
Chris Ohk
 
Agent57: Outperforming the Atari Human Benchmark, Badia, A. P. et al, 2020
Agent57: Outperforming the Atari Human Benchmark, Badia, A. P. et al, 2020
Chris Ohk
 
Proximal Policy Optimization Algorithms, Schulman et al, 2017
Proximal Policy Optimization Algorithms, Schulman et al, 2017
Chris Ohk
 
Trust Region Policy Optimization, Schulman et al, 2015
Trust Region Policy Optimization, Schulman et al, 2015
Chris Ohk
 
Continuous Control with Deep Reinforcement Learning, lillicrap et al, 2015
Continuous Control with Deep Reinforcement Learning, lillicrap et al, 2015
Chris Ohk
 
GDG Gwangju DevFest 2019 - <하스스톤> 강화학습 환경 개발기
GDG Gwangju DevFest 2019 - <하스스톤> 강화학습 환경 개발기
Chris Ohk
 
[RLKorea] <하스스톤> 강화학습 환경 개발기
[RLKorea] <하스스톤> 강화학습 환경 개발기
Chris Ohk
 
[NDC 2019] 하스스톤 강화학습 환경 개발기
[NDC 2019] 하스스톤 강화학습 환경 개발기
Chris Ohk
 
C++20 Key Features Summary
C++20 Key Features Summary
Chris Ohk
 
[델리만주] 대학원 캐슬 - 석사에서 게임 프로그래머까지
[델리만주] 대학원 캐슬 - 석사에서 게임 프로그래머까지
Chris Ohk
 
디미고 특강 - 개발을 시작하려는 여러분에게
디미고 특강 - 개발을 시작하려는 여러분에게
Chris Ohk
 
청강대 특강 - 프로젝트 제대로 해보기
청강대 특강 - 프로젝트 제대로 해보기
Chris Ohk
 
[NDC 2018] 유체역학 엔진 개발기
[NDC 2018] 유체역학 엔진 개발기
Chris Ohk
 
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
인프콘 2022 - Rust 크로스 플랫폼 프로그래밍
Chris Ohk
 
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
Chris Ohk
 
Momenti Seminar - 5 Years of RosettaStone
Momenti Seminar - 5 Years of RosettaStone
Chris Ohk
 
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
Chris Ohk
 
Momenti Seminar - A Tour of Rust, Part 2
Momenti Seminar - A Tour of Rust, Part 2
Chris Ohk
 
Momenti Seminar - A Tour of Rust, Part 1
Momenti Seminar - A Tour of Rust, Part 1
Chris Ohk
 
Evolving Reinforcement Learning Algorithms, JD. Co-Reyes et al, 2021
Evolving Reinforcement Learning Algorithms, JD. Co-Reyes et al, 2021
Chris Ohk
 
Adversarially Guided Actor-Critic, Y. Flet-Berliac et al, 2021
Adversarially Guided Actor-Critic, Y. Flet-Berliac et al, 2021
Chris Ohk
 
Agent57: Outperforming the Atari Human Benchmark, Badia, A. P. et al, 2020
Agent57: Outperforming the Atari Human Benchmark, Badia, A. P. et al, 2020
Chris Ohk
 
Proximal Policy Optimization Algorithms, Schulman et al, 2017
Proximal Policy Optimization Algorithms, Schulman et al, 2017
Chris Ohk
 
Trust Region Policy Optimization, Schulman et al, 2015
Trust Region Policy Optimization, Schulman et al, 2015
Chris Ohk
 
Continuous Control with Deep Reinforcement Learning, lillicrap et al, 2015
Continuous Control with Deep Reinforcement Learning, lillicrap et al, 2015
Chris Ohk
 
GDG Gwangju DevFest 2019 - <하스스톤> 강화학습 환경 개발기
GDG Gwangju DevFest 2019 - <하스스톤> 강화학습 환경 개발기
Chris Ohk
 
[RLKorea] <하스스톤> 강화학습 환경 개발기
[RLKorea] <하스스톤> 강화학습 환경 개발기
Chris Ohk
 
[NDC 2019] 하스스톤 강화학습 환경 개발기
[NDC 2019] 하스스톤 강화학습 환경 개발기
Chris Ohk
 
C++20 Key Features Summary
C++20 Key Features Summary
Chris Ohk
 
[델리만주] 대학원 캐슬 - 석사에서 게임 프로그래머까지
[델리만주] 대학원 캐슬 - 석사에서 게임 프로그래머까지
Chris Ohk
 
디미고 특강 - 개발을 시작하려는 여러분에게
디미고 특강 - 개발을 시작하려는 여러분에게
Chris Ohk
 
청강대 특강 - 프로젝트 제대로 해보기
청강대 특강 - 프로젝트 제대로 해보기
Chris Ohk
 
[NDC 2018] 유체역학 엔진 개발기
[NDC 2018] 유체역학 엔진 개발기
Chris Ohk
 

Recently uploaded (20)

10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 

C++ Programming - 4th Study

  • 3. 3
  • 4. int main() { // int& ref; int i = 10; int& ref = i; ref += 10; std::cout << "i = " << i << std::endl; std::cout << "ref = " << ref << std::endl; return 0; } 4
  • 5. void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } int main() { int a = 10, b = 20; std::cout << "a = " << a << ", b = " << b << std::endl; swap(&a, &b); std::cout << "a = " << a << ", b = " << b << std::endl; return 0; } Pass-by-pointer 5
  • 6. void swap(int& a, int& b) { int temp = a; a = b; b = temp; } int main() { int a = 10, b = 20; std::cout << "a = " << a << ", b = " << b << std::endl; swap(a, b); std::cout << "a = " << a << ", b = " << b << std::endl; return 0; } Pass-by-reference 6
  • 8. 8
  • 9. 9
  • 10. int computeRectArea1(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { return 0; } int computeRectArea2(int width, int height) { return 0; } int main() { int area1 = computeRectArea1(1, 1, 1, 4, 3, 4, 3, 1); int area2 = computeRectArea2(2, 3); return 0; } C 10
  • 11. int computeRectArea(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { return 0; } int computeRectArea(int width, int height) { return 0; } int main() { int area1 = computeRectArea(1, 1, 1, 4, 3, 4, 3, 1); int area2 = computeRectArea(2, 3); return 0; } C++ 11
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. void print() { std::cout << "A's print" << std::endl; } void print() { std::cout << "B's print" << std::endl; } int main() { print(); return 0; } C 16
  • 17. namespace A { void print() { std::cout << "A's print()" << std::endl; } } namespace B { void print() { std::cout << "B's print()" << std::endl; } } int main() { A::print(); B::print(); return 0; } C++ 17
  • 19. C++ using namespace std; namespace A { void print() { cout << "A's print()" << endl; } } namespace B { void print() { cout << "B's print()" << endl; } } int main() { A::print(); B::print(); } 19
  • 20. namespace A { int i; } namespace B { int i; } using namespace A; using namespace B; int main() { // Don't do this if (i == i) { } if (A::i == B::i) { } return 0; } 20