c++ - func(QWidget* const &widget) VS func(QWidget* const widget) -


i've noticed peace of code works throwing away ampersand/reference signal.

qwidget* widget; func(widget); 

do following expressions mean same?

func(qwidget* const &widget) func(qwidget* const widget) 

i understand both pointers cannot modified stuff can modified.

an answer focused on practical effects of both more valuable.

read definitions right-to-left:

the first means: widget reference const pointer qwidget object

qwidget* const &widget 

the second means: widget const pointer qwidget object

func(qwidget* const widget) 

of course not same.

both definitions work because references automatically derenferenced compiler.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -