C++ How reference works behind the scenes [duplicate]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This question already has an answer here:
How is reference implemented internally?
7 answers
For example in
int *a = 5;
MyFunc(&a);
What are the behind the scenes working of '&' Is it just creating a pointer to the pointer and deferencing it automatically? or is it doing something different.
Is there any way to pass by "true" reference in C++ or will everything be a pointer passed by value?
c++ pointers reference
marked as duplicate by πάντα ῥεῖ
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How is reference implemented internally?
7 answers
For example in
int *a = 5;
MyFunc(&a);
What are the behind the scenes working of '&' Is it just creating a pointer to the pointer and deferencing it automatically? or is it doing something different.
Is there any way to pass by "true" reference in C++ or will everything be a pointer passed by value?
c++ pointers reference
marked as duplicate by πάντα ῥεῖ
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
4
I don't see any references here.&a
is not a reference, it is an address ofa
, it has typeint**
.
– Evg
Nov 16 '18 at 11:06
add a comment |
This question already has an answer here:
How is reference implemented internally?
7 answers
For example in
int *a = 5;
MyFunc(&a);
What are the behind the scenes working of '&' Is it just creating a pointer to the pointer and deferencing it automatically? or is it doing something different.
Is there any way to pass by "true" reference in C++ or will everything be a pointer passed by value?
c++ pointers reference
This question already has an answer here:
How is reference implemented internally?
7 answers
For example in
int *a = 5;
MyFunc(&a);
What are the behind the scenes working of '&' Is it just creating a pointer to the pointer and deferencing it automatically? or is it doing something different.
Is there any way to pass by "true" reference in C++ or will everything be a pointer passed by value?
This question already has an answer here:
How is reference implemented internally?
7 answers
c++ pointers reference
c++ pointers reference
asked Nov 16 '18 at 11:00
ProdigleProdigle
1,048317
1,048317
marked as duplicate by πάντα ῥεῖ
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by πάντα ῥεῖ
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
4
I don't see any references here.&a
is not a reference, it is an address ofa
, it has typeint**
.
– Evg
Nov 16 '18 at 11:06
add a comment |
4
I don't see any references here.&a
is not a reference, it is an address ofa
, it has typeint**
.
– Evg
Nov 16 '18 at 11:06
4
4
I don't see any references here.
&a
is not a reference, it is an address of a
, it has type int**
.– Evg
Nov 16 '18 at 11:06
I don't see any references here.
&a
is not a reference, it is an address of a
, it has type int**
.– Evg
Nov 16 '18 at 11:06
add a comment |
1 Answer
1
active
oldest
votes
References in C++ are basically implemented as pointers. I would assume that's how they're implemented in all languages, not just C++.
There's an earlier question with better answers here: How is reference implemented internally?
So, why the downvote?
– James
Nov 16 '18 at 11:37
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
References in C++ are basically implemented as pointers. I would assume that's how they're implemented in all languages, not just C++.
There's an earlier question with better answers here: How is reference implemented internally?
So, why the downvote?
– James
Nov 16 '18 at 11:37
add a comment |
References in C++ are basically implemented as pointers. I would assume that's how they're implemented in all languages, not just C++.
There's an earlier question with better answers here: How is reference implemented internally?
So, why the downvote?
– James
Nov 16 '18 at 11:37
add a comment |
References in C++ are basically implemented as pointers. I would assume that's how they're implemented in all languages, not just C++.
There's an earlier question with better answers here: How is reference implemented internally?
References in C++ are basically implemented as pointers. I would assume that's how they're implemented in all languages, not just C++.
There's an earlier question with better answers here: How is reference implemented internally?
answered Nov 16 '18 at 11:04
JamesJames
1295
1295
So, why the downvote?
– James
Nov 16 '18 at 11:37
add a comment |
So, why the downvote?
– James
Nov 16 '18 at 11:37
So, why the downvote?
– James
Nov 16 '18 at 11:37
So, why the downvote?
– James
Nov 16 '18 at 11:37
add a comment |
4
I don't see any references here.
&a
is not a reference, it is an address ofa
, it has typeint**
.– Evg
Nov 16 '18 at 11:06