C++ Programming - OOPS Concepts - Discussion

Discussion :: OOPS Concepts - General Questions (Q.No.7)

7. 

Which of the following concept of oops allows compiler to insert arguments in a function call if it is not specified?

[A]. Call by value
[B]. Call by reference
[C]. Default arguments
[D]. Call by pointer

Answer: Option C

Explanation:

No answer description available for this question.

Sowmya said: (Jul 18, 2012)  
How come default arguments can you please explain ?

Gaurav Walia said: (Jul 18, 2012)  
Here it means that suppose you have not given any argument in the function call so by default it would take a value you already specified. This is called function with default parameters.

Jaydeep Pandya said: (Sep 12, 2012)  
But how to apply default parameters.

Sri said: (Sep 28, 2012)  
Actuvally primitive data types are used call by valu where as objects are passed by call by reference. About default arguments if we are not give the arguments compiler set the default arguments.

Harish said: (Mar 10, 2013)  
Difference b/w call by reference and call by pointer ?

Saroj said: (Mar 27, 2013)  
Call by reference means call by address thats it.

Vish said: (Apr 30, 2013)  
Actually I made the guess by thinking that call by reference and call by pointer is one and the same thing and concept of call by value is clear from which we can easily conclude that answer will be the option 'C'.

Venkatareddy said: (May 28, 2013)  
Difference between call by value & call by pointer & call by reference perfect answer give me?

Devyashish Mayank said: (Jun 16, 2013)  
For call by value it means we pass a certain value (a no. ) to the function as parameter. While in case of call by pointer it means that we pass a pointer as an argument to it which points to certain address. In case of call by reference we simply provide an address to the function as an argument or parameter to get the desired result.

Lachu said: (Sep 18, 2013)  
The difference between the call by value and call by reference are :The original value is not affected in call by value. That is only copies the value. Original value is affected in call by reference. That is value is changed after calling it.

Revathi said: (Oct 9, 2013)  
Give an example program for each call by value, call by reference, call by pointer.

Amol said: (Oct 22, 2013)  
Eg : Call by value.

include <stdio.h>

/* function declaration */
void swap(int x, int y);

int main ()
{
/* local variable definition */
int a = 100;
int b = 200;

printf("Before swap, value of a : %d\n", a );
printf("Before swap, value of b : %d\n", b );

/* calling a function to swap the values */
swap(a, b);

printf("After swap, value of a : %d\n", a );
printf("After swap, value of b : %d\n", b );

return 0;
}

Eg : call by reference & call by pointer one all the same.

#include <stdio.h>

/* function declaration */
void swap(int *x, int *y);

int main ()
{
/* local variable definition */
int a = 100;
int b = 200;

printf("Before swap, value of a : %d\n", a );
printf("Before swap, value of b : %d\n", b );

/* calling a function to swap the values.
* &a indicates pointer to a ie. address of variable a and
* &b indicates pointer to b ie. address of variable b.
*/
swap(&a, &b);

printf("After swap, value of a : %d\n", a );
printf("After swap, value of b : %d\n", b );

return 0;
}

Manish said: (Dec 21, 2013)  
Please clarify me What is the difference between call by pointers and call by reference? Explain it with e.g.

Prashant Sable said: (May 27, 2014)  
In call reference we pass address so actual parameter value get change.

In call by value formal parameter get copied into actual parameter so actual parameter doesn't change as both have different memory.

Nikhil said: (Jun 4, 2014)  
Pointer also carries a address n reference also carries a address then what is the difference between call by pointer and call by reference.

Ash said: (Jan 22, 2015)  
In call by value we directly pass value and in call by reference we pass address of that value.

Shalu said: (Mar 6, 2015)  
In call by reference: We passes the value in calling time.

And call by reference: We pass the address in calling time.

Call by reference:

void swap(int &x, int &y)
{
..
....

}

swap(a, b);
call by pointer:
void swap(int *x, int *y)
{
...
..

}

swap(&a, &b);

Guru said: (Apr 8, 2015)  
What is mean by call by value, call by Reference and its difference?

Nithyapriya said: (Jun 11, 2015)  
If it specifies means what is the answer?

Sakthi said: (Jul 12, 2015)  
Hi @Amol.

What was the out put of the example program?

Durgesh said: (Jan 25, 2017)  
It means that suppose you have not given any argument in the function call so by default it would take a value you already specified. This is called a function with default parameters.

Piyush said: (Sep 10, 2019)  
Default parameters are the parameter used when not any other parameters are given.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.