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;
}







-2
















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?










share|improve this question













marked as duplicate by πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

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 of a, it has type int**.

    – Evg
    Nov 16 '18 at 11:06




















-2
















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?










share|improve this question













marked as duplicate by πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

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 of a, it has type int**.

    – Evg
    Nov 16 '18 at 11:06
















-2












-2








-2









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?










share|improve this question















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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 11:00









ProdigleProdigle

1,048317




1,048317




marked as duplicate by πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

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 πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

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 of a, it has type int**.

    – Evg
    Nov 16 '18 at 11:06
















  • 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










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














1 Answer
1






active

oldest

votes


















-2














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?






share|improve this answer
























  • So, why the downvote?

    – James
    Nov 16 '18 at 11:37


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-2














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?






share|improve this answer
























  • So, why the downvote?

    – James
    Nov 16 '18 at 11:37
















-2














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?






share|improve this answer
























  • So, why the downvote?

    – James
    Nov 16 '18 at 11:37














-2












-2








-2







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?






share|improve this answer













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?







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 11:04









JamesJames

1295




1295













  • 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





So, why the downvote?

– James
Nov 16 '18 at 11:37





Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues