SlideShare a Scribd company logo
1 of 2
Download to read offline
How are objects passed as parameters? Why is it said that the actual parameter and the formal
parameter become aliases.
Solution
==================================================================
---------------
Answer:
---------------
Objects are passed by reference of the object from the caller. Objects typically holds reference
(Address mapped to memory).
Since Objects holds memory address, which can not be send as pass by value, It must be send
to function using pass by reference.
When an object is given as parameter to a function caller. The actual parameter will be passed
as a reference and formal parameter becomes
alias during the function call.
------------------------------------------------
Let us consider this example:
------------------------------------------------
#include
#include
using namespace std;
//Rectangle class
class Rectangle {
public:
int l;
int b;
//Parametized constrcutor
Rectangle(int lParam,int bParam) {
l = lParam;
b = bParam;
}
};
//A method which takes objects as argument
void printRectangleDimensions(Rectangle rec) {
cout<<" --- Rectangle Dimensions ---  ";
cout<<"Length: "<

More Related Content

More from footstatus

a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdfa) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
footstatus
 

More from footstatus (20)

Water is essential to all living organisms. Discuss THREE properties .pdf
Water is essential to all living organisms. Discuss THREE properties .pdfWater is essential to all living organisms. Discuss THREE properties .pdf
Water is essential to all living organisms. Discuss THREE properties .pdf
 
tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdftree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
tree to answer question 2. n Arabidopsis arenosa Arabidopsis halleri .pdf
 
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdfThe plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
The plant pathogen Xylella fastidiosa is a gram negative that attach.pdf
 
The region labeled with the letter B is transcribed into mRNA True.pdf
The region labeled with the letter B is transcribed into mRNA  True.pdfThe region labeled with the letter B is transcribed into mRNA  True.pdf
The region labeled with the letter B is transcribed into mRNA True.pdf
 
The positron decay of 15 o goes directly to the ground state of,15 N;.pdf
The positron decay of 15 o goes directly to the ground state of,15 N;.pdfThe positron decay of 15 o goes directly to the ground state of,15 N;.pdf
The positron decay of 15 o goes directly to the ground state of,15 N;.pdf
 
a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdfa) What is the Chromosome Theory of Inheritance and how was it deter.pdf
a) What is the Chromosome Theory of Inheritance and how was it deter.pdf
 
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdfQuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
QuestionProblem 1 In a source file carddeck.cpp, provide an impl.pdf
 
provide a brief definition of self assemblySolutionMolecular s.pdf
provide a brief definition of self assemblySolutionMolecular s.pdfprovide a brief definition of self assemblySolutionMolecular s.pdf
provide a brief definition of self assemblySolutionMolecular s.pdf
 
Match the Statements below with bacteriological tests. Eosin-methyle.pdf
Match the Statements below with bacteriological tests.  Eosin-methyle.pdfMatch the Statements below with bacteriological tests.  Eosin-methyle.pdf
Match the Statements below with bacteriological tests. Eosin-methyle.pdf
 
Many non-scientists have focused their criticism of evolution on the.pdf
Many non-scientists have focused their criticism of evolution on the.pdfMany non-scientists have focused their criticism of evolution on the.pdf
Many non-scientists have focused their criticism of evolution on the.pdf
 
It has been observed that F_st increases with the distance between po.pdf
It has been observed that F_st increases with the distance between po.pdfIt has been observed that F_st increases with the distance between po.pdf
It has been observed that F_st increases with the distance between po.pdf
 
Let R be an integral domain and F a field such that R is a subring of.pdf
Let R be an integral domain and F a field such that R is a subring of.pdfLet R be an integral domain and F a field such that R is a subring of.pdf
Let R be an integral domain and F a field such that R is a subring of.pdf
 
Judith, Martha, and Sophia are organizing their backpacks. While org.pdf
Judith, Martha, and Sophia are organizing their backpacks. While org.pdfJudith, Martha, and Sophia are organizing their backpacks. While org.pdf
Judith, Martha, and Sophia are organizing their backpacks. While org.pdf
 
A population of 10,000 students spends an average of $8.50 a day on .pdf
A population of 10,000 students spends an average of $8.50 a day on .pdfA population of 10,000 students spends an average of $8.50 a day on .pdf
A population of 10,000 students spends an average of $8.50 a day on .pdf
 
a local fan club surveyed 67 of its members regarding their viewing .pdf
a local fan club surveyed 67 of its members regarding their viewing .pdfa local fan club surveyed 67 of its members regarding their viewing .pdf
a local fan club surveyed 67 of its members regarding their viewing .pdf
 
A gas is a fluid. It has less molecular space and freedom of motion t.pdf
A gas is a fluid. It has less molecular space and freedom of motion t.pdfA gas is a fluid. It has less molecular space and freedom of motion t.pdf
A gas is a fluid. It has less molecular space and freedom of motion t.pdf
 
A man accidentally let his parakeet out the door. The bird flew up to.pdf
A man accidentally let his parakeet out the door. The bird flew up to.pdfA man accidentally let his parakeet out the door. The bird flew up to.pdf
A man accidentally let his parakeet out the door. The bird flew up to.pdf
 
A culture of yeast was grown in a media containing sucrose labeled b.pdf
A culture of yeast was grown in a media containing sucrose labeled b.pdfA culture of yeast was grown in a media containing sucrose labeled b.pdf
A culture of yeast was grown in a media containing sucrose labeled b.pdf
 
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdfa. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
a. Dipole b. Set of a finite number of point charges c. A uniformly c.pdf
 
5. When a phosphate group is found in water a) The partially-negati.pdf
5. When a phosphate group is found in water a) The partially-negati.pdf5. When a phosphate group is found in water a) The partially-negati.pdf
5. When a phosphate group is found in water a) The partially-negati.pdf
 

Recently uploaded

Recently uploaded (20)

Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
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
 
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
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
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
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
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...
 
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
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

How are objects passed as parameters Why is it said that the actual.pdf

  • 1. How are objects passed as parameters? Why is it said that the actual parameter and the formal parameter become aliases. Solution ================================================================== --------------- Answer: --------------- Objects are passed by reference of the object from the caller. Objects typically holds reference (Address mapped to memory). Since Objects holds memory address, which can not be send as pass by value, It must be send to function using pass by reference. When an object is given as parameter to a function caller. The actual parameter will be passed as a reference and formal parameter becomes alias during the function call. ------------------------------------------------ Let us consider this example: ------------------------------------------------ #include #include using namespace std; //Rectangle class class Rectangle { public: int l; int b; //Parametized constrcutor Rectangle(int lParam,int bParam) { l = lParam; b = bParam;
  • 2. } }; //A method which takes objects as argument void printRectangleDimensions(Rectangle rec) { cout<<" --- Rectangle Dimensions --- "; cout<<"Length: "<