SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
#include <iostream>
/**
* Test class.
*/
class Class
{
/**
* Constructor.
*/
int _id;
public:
/**
* Constructor.
*/
Class(int id = 0): _id(id)
{ std::cout << "Constructor Invocation! Id: " << _id << std::endl; };
/**
* Id Method.
*/
void id(int myid){ _id = myid;}
/**
* Run method.
*/
void run(void)
{ std::cout << "Running! Id: " << _id << std::endl; };
/**
* Destructor.
*/
virtual ~Class(void)
{ std::cout << "Destructor Invocation! Id: " << _id << std::endl;}
};
// Function with passing parameter by value
void TestFunction(Class c){ c.id(1); c.run(); };
// Function with explicit parameter passing by reference.
void TestFunction(Class* c){ c->run(); };
// Function with parameter passing by automatic dereference.
void TestFunction2(Class& c) {
c.run(); };
int main(void)
{
Class c(0);
std::cout << "n@@@" << std::endl;
TestFunction(c);
std::cout << "@@@" << "nn";
std::cout << "---" << std::endl;
TestFunction(4);
std::cout << "---" << "nn";
std::cout << "+++" << std::endl;
TestFunction(&c);
std::cout << "+++" << "nn";
std::cout << "$$$" << std::endl;
TestFunction2(c);
std::cout << "$$$" << "nn";
return 0;
}

Weitere ähnliche Inhalte

Was ist angesagt?

Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
Richard Paul
 

Was ist angesagt? (10)

運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
Javascript ES6
Javascript ES6Javascript ES6
Javascript ES6
 
Sonar rules in action with walkmod
Sonar rules in action with walkmodSonar rules in action with walkmod
Sonar rules in action with walkmod
 
Angular 2.0 Pipes
Angular 2.0 PipesAngular 2.0 Pipes
Angular 2.0 Pipes
 
BarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformationsBarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformations
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
 
Checking Oracle VM VirtualBox. Part 2
Checking Oracle VM VirtualBox. Part 2Checking Oracle VM VirtualBox. Part 2
Checking Oracle VM VirtualBox. Part 2
 
Notes for xx_use_serialgc
Notes for xx_use_serialgcNotes for xx_use_serialgc
Notes for xx_use_serialgc
 
Unit testing concurrent code
Unit testing concurrent codeUnit testing concurrent code
Unit testing concurrent code
 

Andere mochten auch

Andere mochten auch (12)

Documentation - Reference Manual - SysSorting
Documentation - Reference Manual - SysSortingDocumentation - Reference Manual - SysSorting
Documentation - Reference Manual - SysSorting
 
Intelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color PalettesIntelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color Palettes
 
A Framework for Harmonic Color Measures
A Framework for Harmonic Color MeasuresA Framework for Harmonic Color Measures
A Framework for Harmonic Color Measures
 
Texture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU UseTexture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU Use
 
Effectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment IndexesEffectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment Indexes
 
Introduction to Kernel Functions
Introduction to Kernel FunctionsIntroduction to Kernel Functions
Introduction to Kernel Functions
 
Graph Theory - Exercises - Chapter 2 - Part II
Graph Theory - Exercises - Chapter 2 - Part IIGraph Theory - Exercises - Chapter 2 - Part II
Graph Theory - Exercises - Chapter 2 - Part II
 
Report - Lex and YACC
Report -  Lex and YACCReport -  Lex and YACC
Report - Lex and YACC
 
ID3 Algorithm - Reference Manual
ID3 Algorithm - Reference ManualID3 Algorithm - Reference Manual
ID3 Algorithm - Reference Manual
 
Graph Theory - Exercises - Chapter 3 - Algorithms of Dijkstra and Bellman-Ford
Graph Theory - Exercises - Chapter 3 - Algorithms of Dijkstra and Bellman-FordGraph Theory - Exercises - Chapter 3 - Algorithms of Dijkstra and Bellman-Ford
Graph Theory - Exercises - Chapter 3 - Algorithms of Dijkstra and Bellman-Ford
 
Graph Theory - Exercises - Chapter 3
Graph Theory - Exercises - Chapter 3Graph Theory - Exercises - Chapter 3
Graph Theory - Exercises - Chapter 3
 
Graph Theory - Exercises - Chapters 2, 3, 4, 5, 6, 7, 8, and 9
Graph Theory - Exercises - Chapters 2, 3, 4, 5, 6, 7, 8, and 9Graph Theory - Exercises - Chapters 2, 3, 4, 5, 6, 7, 8, and 9
Graph Theory - Exercises - Chapters 2, 3, 4, 5, 6, 7, 8, and 9
 

Ähnlich wie Test Passing Parameters in C++.

Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
Dendi Riadi
 
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptxCONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
DeepasCSE
 
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
MARRY7
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile Development
Jan Rybák Benetka
 
Csharp4 inheritance
Csharp4 inheritanceCsharp4 inheritance
Csharp4 inheritance
Abed Bukhari
 
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxDAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
theodorelove43763
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
tidwellveronique
 

Ähnlich wie Test Passing Parameters in C++. (20)

Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Object Calisthenics em Go
Object Calisthenics em GoObject Calisthenics em Go
Object Calisthenics em Go
 
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCECONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
CONSTRUCTORS IN C++ +2 COMPUTER SCIENCE
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptxCONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
CONSTRUCTORS, DESTRUCTORS AND OPERATOR OVERLOADING.pptx
 
UI testing in Xcode 7
UI testing in Xcode 7UI testing in Xcode 7
UI testing in Xcode 7
 
Vocabulary Types in C++17
Vocabulary Types in C++17Vocabulary Types in C++17
Vocabulary Types in C++17
 
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
 
Constructor and Destructors in C++
Constructor and Destructors in C++Constructor and Destructors in C++
Constructor and Destructors in C++
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile Development
 
Working with Cocoa and Objective-C
Working with Cocoa and Objective-CWorking with Cocoa and Objective-C
Working with Cocoa and Objective-C
 
Making Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVMMaking Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVM
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Csharp4 inheritance
Csharp4 inheritanceCsharp4 inheritance
Csharp4 inheritance
 
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxDAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
 
Day 1
Day 1Day 1
Day 1
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
 
C++ L05-Functions
C++ L05-FunctionsC++ L05-Functions
C++ L05-Functions
 
Nick: A Nearly Headless CMS
Nick: A Nearly Headless CMSNick: A Nearly Headless CMS
Nick: A Nearly Headless CMS
 

Mehr von Michel Alves

Harris Detector Results
Harris Detector ResultsHarris Detector Results
Harris Detector Results
Michel Alves
 

Mehr von Michel Alves (20)

About Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV SpaceAbout Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV Space
 
Color Harmonization - Results
Color Harmonization - ResultsColor Harmonization - Results
Color Harmonization - Results
 
Wave Simulation Using Perlin Noise
Wave Simulation Using Perlin NoiseWave Simulation Using Perlin Noise
Wave Simulation Using Perlin Noise
 
Similarity Maps Using SSIM Index
Similarity Maps Using SSIM IndexSimilarity Maps Using SSIM Index
Similarity Maps Using SSIM Index
 
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color HarmonizationQualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
 
TMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsTMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and Reports
 
Month Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJMonth Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJ
 
Color Palettes in R
Color Palettes in RColor Palettes in R
Color Palettes in R
 
Sigmoid Curve Erf
Sigmoid Curve ErfSigmoid Curve Erf
Sigmoid Curve Erf
 
Hue Wheel Prototype
Hue Wheel PrototypeHue Wheel Prototype
Hue Wheel Prototype
 
Cosine Curve
Cosine CurveCosine Curve
Cosine Curve
 
Triangle Mesh Plot
Triangle Mesh PlotTriangle Mesh Plot
Triangle Mesh Plot
 
Triangle Plot
Triangle PlotTriangle Plot
Triangle Plot
 
Capacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video SlidesCapacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video Slides
 
Capacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function CatalogCapacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function Catalog
 
Capacity-Constrained Point Distributions :: Complementary Results
Capacity-Constrained Point Distributions :: Complementary ResultsCapacity-Constrained Point Distributions :: Complementary Results
Capacity-Constrained Point Distributions :: Complementary Results
 
Capacity-Constrained Point Distributions
Capacity-Constrained Point DistributionsCapacity-Constrained Point Distributions
Capacity-Constrained Point Distributions
 
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
Five Minute Speech: An Overview of Activities Developed in Disciplines and Gu...
 
Harris Detector Results
Harris Detector ResultsHarris Detector Results
Harris Detector Results
 
Class Diagram - MyImageLibrary
Class Diagram - MyImageLibraryClass Diagram - MyImageLibrary
Class Diagram - MyImageLibrary
 

Kürzlich hochgeladen

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
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Kürzlich hochgeladen (20)

Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
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
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
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Ữ Â...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
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.
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

Test Passing Parameters in C++.

  • 1. #include <iostream> /** * Test class. */ class Class { /** * Constructor. */ int _id; public: /** * Constructor. */ Class(int id = 0): _id(id) { std::cout << "Constructor Invocation! Id: " << _id << std::endl; }; /** * Id Method. */ void id(int myid){ _id = myid;} /** * Run method. */ void run(void) { std::cout << "Running! Id: " << _id << std::endl; }; /** * Destructor. */ virtual ~Class(void) { std::cout << "Destructor Invocation! Id: " << _id << std::endl;} }; // Function with passing parameter by value void TestFunction(Class c){ c.id(1); c.run(); }; // Function with explicit parameter passing by reference. void TestFunction(Class* c){ c->run(); }; // Function with parameter passing by automatic dereference. void TestFunction2(Class& c) { c.run(); }; int main(void) { Class c(0); std::cout << "n@@@" << std::endl; TestFunction(c); std::cout << "@@@" << "nn"; std::cout << "---" << std::endl; TestFunction(4); std::cout << "---" << "nn"; std::cout << "+++" << std::endl; TestFunction(&c); std::cout << "+++" << "nn"; std::cout << "$$$" << std::endl; TestFunction2(c); std::cout << "$$$" << "nn"; return 0; }