Please explain the reference variable in c++?



Please explain the reference variable in c++?..

Answer / Aditya

A reference in C++ is an alias for an existing object. It allows multiple names to refer to a single entity, providing an efficient way to pass large objects as function arguments or to improve readability by using descriptive names for complex expressions.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What do you mean by global variables?

1 Answers  


How much is size of struct having 1 char & 1 integer?

11 Answers   Persistent,


What are references in c++?

1 Answers  


write a program to insert an element into an array

26 Answers   TCS,


What is c++ in english?

1 Answers  


Find out the bug in this code,because of that this code will not compile....... #include <iostream> #include <new> #include <cstring> using namespace std; class balance { double cur_bal; char name[80]; public: balance(double n, char *s) { cur_bal = n; strcpy(name, s); } ~balance() { cout << "Destructing "; cout << name << "\n"; } void set(double n, char *s) { cur_bal = n; strcpy(name, s); } void get_bal(double &n, char *s) { n = cur_bal; strcpy(s, name); } }; int main() { balance *p; char s[80]; double n; int i; try { p = new balance [3]; // allocate entire array } catch (bad_alloc xa) { cout << "Allocation Failure\n"; return 1; }

2 Answers   Impetus,


What are the popular tools used to detect memory leaks in c++

4 Answers   TATA,


How did c++ start?

1 Answers  


Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .

1 Answers  


What is the average salary of a c++ programmer?

1 Answers  


What is the purpose of template?

1 Answers  


In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest.

5 Answers   GE,


Categories