How to create a reference variable in C++



How to create a reference variable in C++..

Answer / hrpynux@gmail.com

When a variable is declared as a reference, it becomes an alternative name for an existing variable. A variable can be declared as a reference by putting '&' in the declaration.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;

0 Answers  


Is java made in c++?

0 Answers  


can any one help to find a specific string between html tags which is changed to a sting.. weather.html looks (for location) is <location>somewhere</location> #include <iostream> #include <fstream> #include <string> using namespace std; string find_field(string myPage,string); int main (void) { string page, line, location, temperature; ifstream inputFile("weather.xml"); while(getline(inputFile, line)) { page.append(line); line.erase(); } // Now page is a string that contains the whole xml page // Here you need to write something that finds and // extracts location and temperature from the XML // data in the string page and stores them in // the strings location and temperature respectively location=find_field(page,"location"); temperature=find_field(page,"temp_c"); cout << "Location: "<<location << endl; cout << "Temperature: " << temperature << endl; system("pause"); } string find_field(string myPage,string find_string){ int temp=myPage.find(find_string); if(temp!=string::npos) { cout << "Match found at " << temp << endl; } return "found?"; } ///

0 Answers  


Can I learn c++ in a week?

0 Answers  


How can we access protected and private members of a class?

0 Answers  






How do I use arrays in c++?

0 Answers  


What is the difference between static link library and dynamic link library?

7 Answers   Tech Mahindra,


What is the real purpose of class – to export data?

0 Answers  


What is the best c++ compiler for windows 10?

0 Answers  


Define a constructor - what it is and how it might be called (2 methods)?

0 Answers  


What is the difference between a pointer and a link in c ++?

0 Answers  


What is the disadvantage of using a macro?

0 Answers  


Categories