What are the differences between a pointer variable and a reference variable

0 votes
What distinguishes a reference variable from a pointer variable?
Jul 11 in C++ by Nicholas
• 5,020 points
21 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C++

0 votes
0 answers

What is the difference between a concrete class and an abstract class?

I'm learning C++, but I'm having trouble ...READ MORE

Jul 26 in C++ by Nicholas
• 5,020 points
8 views
0 votes
1 answer

why are copy constructors needed and what are the cases where they are very helpful?

A copy constructor is a member function ...READ MORE

answered May 31 in C++ by Damon
• 4,960 points
48 views
0 votes
1 answer

What is the difference between std::__gcd and std::gcd?

I done some research about this. The ...READ MORE

answered Jun 10 in C++ by Damon
• 4,960 points
58 views
0 votes
1 answer

C++ code file extension? What is the difference between .cc and .cpp [closed]

GNU GCC recognizes all of the following ...READ MORE

answered Jun 21 in C++ by Damon
• 4,960 points
17 views
0 votes
1 answer

What is the difference between public, private, and protected inheritance in C++?

To begin answering that question, let me characterise member accessors in my own terms.  If you already know this, proceed to the section "next:". I'm aware of three types of accessors: public, protected, and private. Let: class Base { public: ...READ MORE

answered Jul 11 in C++ by Damon
• 4,960 points
31 views
0 votes
0 answers

What is the difference between ifstream, ofstream and fstream?

I stumbled discovered ifstream, ofstream, and fstream ...READ MORE

Jul 11 in C++ by Nicholas
• 5,020 points
22 views
0 votes
1 answer

What is a smart pointer and when should I use one?

A smart pointer is similar to a ...READ MORE

answered Jun 2 in C++ by Damon
• 4,960 points
19 views
0 votes
1 answer

Why should I use reference variables at all?

References themselves are unrelated to the issue. The issue is because C++ manages object lifetimes differently from run-time systems that employ garbage collectors, such as Java.  There is no standard built-in garbage collector in C++.  Both automatic (within local or global scope) and manual (explicitly allocated/deallocated in heap) object lifetimes are possible in  C++. A C++ reference is nothing more than an object's alias.  It has no knowledge of object lifespan (for the sake of efficiency).  The coder must give it some thought.  A reference bound to a temporary object is an exception; in this situation, the temporary object's lifespan is prolonged to include the lifetime of the bound reference. References play a crucial role in the fundamental ideas of C++, and they are required for 90% of jobs.  Otherwise, pointers must be used, which is typically far worse. You can use references, for instance, when you need to give an object as a function parameter by reference rather than by value: void f(A copyOfObj); ...READ MORE

answered Aug 5 in C++ by Damon
• 4,960 points
12 views
0 votes
1 answer

What is this weird colon-member (" : ") syntax in the constructor?

Foo(int num): bar(num) In C++, this is known as a Member Initializer List. Simply put, it sets the value of your member bar to num. There is a significant difference between initializing a member with the Member initializer list and assigning a value to it within the function Object() { [native code] } body. When you use the Member initializer list to initialise fields, the constructors are only called once, and the object is constructed and initialised in a single operation. If you use assignment, the fields will be initialised with default constructors and then reassigned with actual values (via the assignment operator). As you can see, there is an extra overhead of creation and assignment in the latter, which may be significant for user defined classes. Cost of Member Initialization =Object ...READ MORE

answered May 27 in Others by Damon
• 4,960 points
45 views
0 votes
1 answer

The Definitive C++ Book Guide and List

For Beginner (includes those without coding experience) Programming: ...READ MORE

answered Jun 6 in C++ by pranav
• 2,580 points
43 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP