Skip to the content

onlineexamguide

  • Home
  • Courses
  • Engg. Interview
    • Electrical Engineering
    • Mechanical Engineering
    • Automobile Engineering
    • Civil Engineering
    • Computer Science Engineering
    • Chemical Engineering
  • Online Exam
    • Aptitude Tricks
    • Computer Knowledge
    • Logical Reasoning Tricks
    • Networking
  • Ghatna Chakra
  • Register
    • Instructor Registration
    • Student Registration
  • User Login
  • Home
  • Courses
  • Engg. Interview
    • Electrical Engineering
    • Mechanical Engineering
    • Automobile Engineering
    • Civil Engineering
    • Computer Science Engineering
    • Chemical Engineering
  • Online Exam
    • Aptitude Tricks
    • Computer Knowledge
    • Logical Reasoning Tricks
    • Networking
  • Ghatna Chakra
  • Register
    • Instructor Registration
    • Student Registration
  • User Login

C ++ References Tutorials :: General Questions –

c++ programming tutorials

In the C++ programming language, a C++ references is a simple reference datatype that is less powerful but safer than the pointer type inherited from C

What is C++ References ?

A reference variable is an alias, that is, another name for an already existing variable. Once a reference is initialized with a variable, either the variable name or the reference name may be used to refer to the variable.

References vs Pointers

References are often confused with pointers but three major differences between references and pointers are −

  • You cannot have NULL references. You must always be able to assume that a reference is connected to a legitimate piece of storage.
  • Once a reference is initialized to an object, it cannot be changed to refer to another object. Pointers can be pointed to another object at any time.
  • A reference must be initialized when it is created. Pointers can be initialized at any time.

Creating References in C++

Think of a variable name as a label attached to the variable’s location in memory. You can then think of a reference as a second label attached to that memory location. Therefore, you can access the contents of the variable through either the original variable name or the reference. For example, suppose we have the following example −

int i = 17;

We can declare reference variables for i as follows.

int& r = i;

Read the & in these declarations as reference. Thus, read the first declaration as “r is an integer reference initialized to i” and read the second declaration as “s is a double reference initialized to d.”. Following example makes use of references on int and double −Live Demo

#include <iostream>
 
using namespace std;
 
int main () {
   // declare simple variables
   int    i;
   double d;
 
   // declare reference variables
   int&    r = i;
   double& s = d;
   
   i = 5;
   cout << "Value of i : " << i << endl;
   cout << "Value of i reference : " << r  << endl;
 
   d = 11.7;
   cout << "Value of d : " << d << endl;
   cout << "Value of d reference : " << s  << endl;
   
   return 0;
}

When the above code is compiled together and executed, it produces the following result −

Value of i : 5
Value of i reference : 5
Value of d : 11.7
Value of d reference : 11.7

References are usually used for function argument lists and function return values. So following are two important subjects related to C++ references which should be clear to a C++ programmer −

Sr.NoConcept & Description
1References as Parameters C++ supports passing references as function parameter more safely than parameters.
2Reference as Return Value You can return reference from a C++ function like any other data type.

C ++ References MCQ Online test

[WpProQuiz 186]

Write a comment Cancel reply

You must be logged in to post a comment.

*
  • किस राज्य/केंद्र शासित प्रदेश ने ‘कोडवा हॉकी महोत्सव’ (Kodava Hockey Festival) की मेजबानी की?

  • उत्तर – कर्नाटक

  • हाल ही में खबरों में रहा बरदा वन्यजीव अभयारण्य (Barda Wildlife Sanctuary) किस राज्य/केंद्र शासित प्रदेश में स्थित है?

  • उत्तर – गुजरात

  • किस देश ने ‘सऊदी-ईरान सम्बन्ध सामान्यीकरण’ शांति समझौते की मध्यस्थता की?

  • उत्तर – चीन

  • ‘संयुक्त राष्ट्र 2023 जल सम्मेलन’ (United Nations 2023 Water Conference) का मेजबान कौन सा देश है?

  • उत्तर – अमेरिका

  • ‘अल-मोहद-अल हिंदी-23’ (Al-Mohed-Al Hindi-23) अभ्यास भारत और किस देश के बीच आयोजित किया जा रहा है?

  • उत्तर – सऊदी अरब

  • सेमी-हाई-स्पीड वंदे भारत एक्सप्रेस ट्रेन चलाने वाली पहली महिला लोको पायलट कौन हैं?

  • उत्तर – सुरेखा यादव

  • भारतीय रिजर्व बैंक ने 2023 तक कितने देशों के बैंकों को रुपये में व्यापार करने की अनुमति दी थी?

  • उत्तर – 18

  • MD15 बसों का प्रायोगिक परीक्षण और M100 (100% मेथनॉल) का प्रोटोटाइप किस शहर में लॉन्च किया गया?

  • उत्तर – बेंगलुरु

  • फरवरी 2023 में भारत में थोक मूल्य सूचकांक (WPI) आधारित मुद्रास्फीति कितनी है?

  • उत्तर – 3.85%

  • किस संस्थान ने एक व्यापक स्व-निगरानी ढांचा ‘ATL सारथी’ लॉन्च किया है?

  • उत्तर – नीति आयोग

  • उस चक्रवात का क्या नाम है जिससे मलावी और मोज़ाम्बिक में तेज़ हवाएँ चलीं और मूसलाधार बारिश हुई?

  • उत्तर – फ्रेडी

  • ऑस्कर 2023 इवेंट के दौरान किस फिल्म ने सात पुरस्कार जीते?

  • उत्तर – Everything Everywhere All at Once

  • MoSPI के हालिया आंकड़ों के अनुसार, फरवरी 2023 में भारत की खुदरा मुद्रास्फीति कितनी दर्ज की गई?

  • उत्तर – 6.44%

  • कौन सा राज्य/केंद्र शासित प्रदेश ‘साझा बौद्ध विरासत पर पहला अंतर्राष्ट्रीय सम्मेलन’ का मेजबान है?

  • उत्तर – नई दिल्ली

  • किस राज्य ने राज्य के कार्यकर्ताओं को राज्य सरकार की नौकरी में 10% क्षैतिज आरक्षण को मंजूरी दी?

  • उत्तर – उत्तराखंड

  • Unique Land Parcel Identification Number (ULPIN) कितने अंकों वाला एक अल्फा-न्यूमेरिक नंबर है?

  • उत्तर – 14

  •  किस संस्था ने ‘Landslide Atlas of India’ जारी किया?

  • उत्तर – इसरो

  • किस केंद्रीय मंत्रालय ने ‘लीन योजना’ (LEAN Scheme) शुरू की?

  • उत्तर – MSME मंत्रालय

  • कौन सा केंद्रीय मंत्रालय ‘World Food India-2023’ कार्यक्रम की मेजबानी करने जा रहा है?

  • उत्तर – खाद्य प्रसंस्करण उद्योग मंत्रालय

  • माधव राष्ट्रीय उद्यान (Madhav National Park), जो हाल ही में खबरों में था, किस राज्य/केंद्र शासित प्रदेश में है?

  • उत्तर – मध्य प्रदेश

  • किस राज्य/केंद्र शासित प्रदेश ने विभिन्न क्षेत्रों में शहर के विकास का मार्गदर्शन करने के लिए ‘2041 के लिए मास्टर प्लान’ जारी किया?

  • उत्तर – नई दिल्ली

  • हाल ही में ख़बरों में रहा ‘Safe Harbour Principle’ किस अधिनियम से संबंधित है?

  • उत्तर – सूचना प्रौद्योगिकी अधिनियम, 2000

  • 2023 में शंघाई सहयोग संगठन (SCO) की अध्यक्षता किस देश के पास है?

  • उत्तर – भारत

  • हाल ही में खबरों में रहा टोरिनो स्केल (Torino Scale) किस क्षेत्र से जुड़ा है?

  • उत्तर – अंतरिक्ष विज्ञान

  • कृत्रिम बुद्धि (artificial intelligence) द्वारा संचालित दुनिया के पहले रेडियो प्लेटफॉर्म का नाम क्या है?

  • उत्तर – RadioGPT

  • नासा के क्यूरियोसिटी रोवर (Curiosity Rover) ने हाल ही में किस ग्रह पर क्रिपस्कुलर किरणों (crepuscular rays) को कैप्चर किया है?

  • उत्तर – मंगल

  • कौन सा केंद्रीय मंत्रालय ‘स्वदेश दर्शन 2.0 कार्यक्रम’ लागू करता है?

  • उत्तर – पर्यटन मंत्रालय

  • हाल ही में Prevention of Money Laundering Act को किन उत्पादों को शामिल करने के लिए विस्तारित किया गया था?

  • उत्तर – वर्चुअल डिजिटल संपत्ति

  • किस देश ने National Platform for Disaster Risk Reduction (NPDRR) के तीसरे सत्र की मेजबानी की?

  • उत्तर – भारत

  • किस राज्य के राज्यपाल ने राज्य मंत्रिमंडल द्वारा पारित ऑनलाइन जुआ निषेध विधेयक (Prohibition of Online Gambling Bill) को लौटा दिया है?

  • उत्तर – तमिलनाडु

  • भारत में पहली बार माइम्युसेमिया सीलोनिका (Mimeusemia ceylonica), दुर्लभ पतंगे की प्रजाति को किस राज्य में देखा गया है?

  • उत्तर – केरल

  • किस देश ने ‘Illegal Migration Bill’ पेश किया?

  • उत्तर – यूके

  • किस देश ने 25 वर्षों में पहली बार महिलाओं के लिए सैन्य सेवा खोली है?

  • उत्तर – कोलंबिया

  • केंद्र ने हाल ही में NAFED, NCCF को किस उत्पाद की खरीद के लिए बाजार में तत्काल हस्तक्षेप करने का निर्देश दिया है?

  • उत्तर – लाल प्याज

  • ‘ट्रोपेक्स 2023’ किस देश द्वारा आयोजित एक प्रमुख परिचालन स्तर का अभ्यास है?

  • उत्तर – भारत

  • किस संस्था ने ‘Global Greenhouse Gas Monitoring Infrastructure’ पेश किया?

  • उत्तर – WMO

  • किस केंद्रीय मंत्रालय ने ‘स्वच्छोत्सव’ महिलाओं के नेतृत्व में स्वच्छता अभियान शुरू किया?

  • उत्तर – आवास और शहरी मामलों के मंत्रालय

  • सल्हौतुओनुओ क्रूस (Salhoutuonuo Kruse) ने किस राज्य की पहली महिला कैबिनेट मंत्री बनकर इतिहास रचा है?

  • उत्तर – नागालैंड

  • कौन सा शहर वित्तीय समावेशन के लिए वैश्विक भागीदारी की दूसरी बैठक का मेजबान था?

  • उत्तर – हैदराबाद

  • डॉ माणिक साहा ने 2023 में किस भारतीय राज्य के मुख्यमंत्री के रूप में शपथ ली?

  • उत्तर – त्रिपुरा

  • ‘डिजिटल इंडिया बिल’ किस केंद्रीय मंत्रालय से जुड़ा है?

  • उत्तर – इलेक्ट्रॉनिक्स और आईटी मंत्रालय

  • ड्राफ्ट केंद्रीय विद्युत प्राधिकरण विनियम (Draft Central Electricity Authority Regulations) हाल ही में किस प्रजाति की रक्षा के लिए जारी किया गया था?

  • उत्तर – ग्रेट इंडियन बस्टर्ड

  • किस देश ने ‘International Big Cat Alliance’ बनाने का प्रस्ताव दिया है?

  • उत्तर – भारत

  • ब्रह्मोस मिसाइल को रूस के NPO मशीनोस्ट्रोयेनिया और भारत के किस संगठन के बीच साझेदारी से विकसित किया गया है?

  • उत्तर – DRDO

  • दुनिया का पहला 200 मीटर लंबा बैंबू क्रैश बैरियर ‘बाहु बल्ली’ किस राज्य में स्थापित किया गया है?

  • उत्तर – महाराष्ट्र

  • किस देश ने लगभग 8.5 मिलियन मीट्रिक टन लिथियम अयस्क की खोज करने का दावा किया है?

  • उत्तर – ईरान

  • किस संस्था ने ‘Women, Business and the Law Index’ जारी किया?

  • उत्तर – विश्व बैंक

  • 2021-22 के लिए आवधिक श्रम बल सर्वेक्षण (PLFS) रिपोर्ट के अनुसार, कृषि क्षेत्र में रोजगार का अंश कितना है?

  • उत्तर – 45.5%

  • किस संस्था ने ‘Advanced Towed Artillery Gun System (ATAGS)’ डिजाइन किया है?

  • उत्तर – DRDO

  • हाल ही में खबरों में रहा HUID नंबर किस तत्व/उत्पाद से जुड़ा है?

  • उत्तर – सोना

  • किन संस्थानों ने ‘More than a billion reasons: The urgent need to build universal social protection’ शीर्षक से रिपोर्ट जारी की?

  • उत्तर – UNICEF- ILO

  • केंद्रीय सिंचाई एवं विद्युत बोर्ड (CBIP) पुरस्कार किस संस्था को प्रदान किया गया?

  • उत्तर – NTPC

  • किस संस्था ने ‘Mind the Gender Gap’ रिपोर्ट जारी की?

  • उत्तर – CFA Institute

  • हाल ही में खबरों में रही ‘समर्थ योजना’ (SAMARTH scheme) किस मंत्रालय से जुड़ी है?

  • उत्तर – कपड़ा मंत्रालय

  • राष्ट्रीय सुरक्षा दिवस (National Safety Day) 2023 की थीम क्या है?

  • उत्तर – Our Aim – Zero Harm

  • कौन सा शहर ‘G20 विदेश मंत्रियों की बैठक (FMM)’ का मेजबान है?

  • उत्तर – नई दिल्ली

  • किस देश ने इंडो-पैसिफिक टेक दूत (Indo-Pacific tech envoy) की घोषणा की?

  • उत्तर – यूके

  • किस बैंक ने सिटीग्रुप के भारतीय उपभोक्ता कारोबार का अधिग्रहण पूरा कर लिया है?

  • उत्तर – Axis Bank

  • किस केंद्रीय मंत्रालय ने ‘Grievance Appellate Committee (GAC)’ लॉन्च की?

  • उत्तर – इलेक्ट्रॉनिक्स और आईटी मंत्रालय

  • ‘Indian States’ Energy Transition’ रिपोर्ट के अनुसार, किन राज्यों ने स्वच्छ बिजली में परिवर्तन में सबसे अधिक प्रगति की है?

  • उत्तर – कर्नाटक और गुजरात

  • धरोई आर्द्रभूमि (Dharoi wetland), जहाँ हाल ही में एक पक्षी सर्वेक्षण किया गया था, किस राज्य में स्थित है?

  • उत्तर – गुजरात

  • IMF के अनुसार, किस देश में 2023 में वैश्विक विकास में 15% योगदान देने की क्षमता है?

  • उत्तर – भारत

  • भारत के किस पड़ोसी देश ने सौर ऊर्जा के उपयोग को बढ़ाने के लिए ISA के साथ समझौता ज्ञापन पर हस्ताक्षर किए?

  • उत्तर – बांग्लादेश

  • अंतर्राष्ट्रीय बौद्धिक संपदा सूचकांक 2023 में भारत का रैंक क्या है?

  • उत्तर – 42

  • कौन सा राज्य ‘वैश्विक उत्तरदायी पर्यटन शिखर सम्मेलन’ (Global Responsible Tourism Summit) का मेजबान है?

  • उत्तर – केरल

  • ‘UPI LITE पेमेंट्स’ लॉन्च करने वाला पहला प्लेटफॉर्म कौन सा है?

  • उत्तर – पेटीएम पेमेंट्स बैंक

  • किस संस्था ने भारत का पहला म्यूनिसिपल बॉन्ड इंडेक्स लॉन्च किया?

  • उत्तर – NSE

  • किस शहर का नाम बदलकर ‘छत्रपति संभाजीनगर’ कर दिया गया है?

  • उत्तर – औरंगाबाद

  • भारत की G-20 अध्यक्षता के तहत W20 इंसेप्शन मीटिंग की मेजबानी कौन सा शहर कर रहा है?

  • उत्तर – औरंगाबाद

  • कौन सा शहर ‘International Bio-resource Conclave & Ethno-pharmacology Congress 2023’ का मेजबान है?

  • उत्तर – इंफाल

  • फेंटानिल और पशु ट्रैंक्विलाइज़र का मिश्रण जिसे ज़ाइलाज़ीन कहा जाता है, जिसे ‘ट्रांक डोप’ के रूप में जाना जाता है, किस देश में चिंता पैदा कर रहा है?

  • उत्तर – अमेरिका

  • किस राज्य को ‘Foundational Literacy and Numeracy Index 2022’ में शीर्ष प्रदर्शन करने वाला स्थान मिला?

  • उत्तर – पश्चिम बंगाल

  • किस देश ने ‘National Green Fiscal Incentives Policy Framework’ लॉन्च किया?

  • उत्तर – केन्या

  • काजीरंगा राष्ट्रीय उद्यान किस राज्य में स्थित है?

  • उत्तर – असम

  • ‘राष्ट्रीय स्वास्थ्य प्राधिकरण की स्कैन एंड शेयर सर्विस’ किस योजना के तहत शुरू की गई थी?

  • उत्तर – आयुष्मान भारत डिजिटल मिशन

  • किस देश ने ‘कमर्शियल आर्म्स ट्रांसफर (CAT) पॉलिसी’ लॉन्च की है?

  • उत्तर – अमेरिका

  • हाल ही में खबरों में रही ‘INS सिंधुकेसरी’ क्या है?

  • उत्तर – पनडुब्बी

  • 2022 में किस देश की प्रजनन दर दुनिया में सबसे कम 0.78 है?

  • उत्तर – दक्षिण कोरिया

  • हाल ही में खबरों में रहा रिड्यू कैनाल स्केटवे (Rideau Canal Skateway) किस देश में है?

  • उत्तर – कनाडा

Recent Posts

  • Synchronous Motors – Important Questions and Answers
  • Starting Methods of Synchronous Motor
  • Torque and Power Relation
  • Phasor Diagram for Synchronous Motor
  • Synchronous Motor: Applications, Starting Methods & Working Principle
  • Prime mover
  • Parallel Operation of Alternators
  • Slip Test on Synchronous Machine
  • Salient Pole and Non Salient Pole Synchronous Generator
  • Power Angle Curve of Synchronous Machine
  • Methods of finding Voltage Regulation in Synchronous Generator
  • Voltage Regulation of Alternator or Synchronous Generator
  • Potier Reactance – Synchronous Generator
  • Short Circuit Ratio of a Synchronous Machine (SCR)
  • Synchronous Reactance and Synchronous Impedance

onlineexamguide

onlineexamguide.com is the ultimate guide that will keep you updated about almost every Exam & Interviews . We aim to provide our readers with an informative details that have been occurring in Examination . Here at onlineexamguide.com , we focus on delivering our readers with the latest exam Pattern Mock test

We Provide Free online test to practice for Competitive exams , Online Exam, Entrance and Interview. Learn and Practice online test for Free and Prepare for your exam online with us

Quick links

  • About us
  • Privacy Policy
  • Instructor Registration
  • Student Registration
  • Java Programming
  • C programming
  • C++ programming
  • Aptitude Tricks

Follow us

Free Online Mock Test

  • UPTET PRIMARY Online Test Series
  • Super TET Mock Test in Hindi 2023
  • CTET Mock Test 2022 Paper 1
  • SSC CHSL Online Mock Test
  • SSC MTS Mock Test 2023
  • SSC CGL Mock Test
  • SSC GD Mock Test
  • ccc online test

Search

Learn and Earn

Register as Instructor - Create and sell online courses and coaching services with the best online platform onlineexamguide.com . Build a course, build a brand, earn money

Contact us

For any queries

Email us on - admin@onlineexamguide.com

We will response fast as much as we can
Copyright © 2023 onlineexamguide.com - All Rights Reserved.
error: Content is protected !!

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.