I have a method:
odp(foo& bar);
I am trying to call it:
foo baz; odp(&baz);
I get a compiler error:
error C2664: "odp" cannot convert parameter 1 from 'foo *' to 'foo &'
What am I doing wrong? Am I passing a link to baz?
baz
UPDATE . Perhaps I have a misconception about the relationship between pointers and links. I thought they were the same, but the links cannot be null. This is not true?
& , , . . , - : lvalue .
&
"" "" ( "pass by pointer" "pass by reference" ) C. ++ .
odp foo var, foo var ().
baz :
foo baz; opd(baz);
.
, baz. &.
& baz, baz, .
++ , , , , . , , "" "" ++.
int i = 5; int &j = i; // j refers to the variable i // wherever the code uses j, it actually uses i j++; // I just changed i from 5 to 6 int *pj = &i; // pj is a pointer to i (*pj)--; // I just changed i back to 5
, pj , j .
int k = 10; pj = &k; // pj now actually points to k (*pj)++; // I just changed k to 11 j = k; // no, this doesn't change the reference j to refer to k instead of i, // but this statement just assigned k to i, that is, i now equals 11!
++ - , . , , .
, , , . , , , . int* int, .
int*
int
, ? C " ", , - "" . ++ , .
foo baz; odp(baz);
Source: https://habr.com/ru/post/1749299/More articles:Вызов функции PL/SQL, которая возвращает {Table}% ROWTYPE из С# - c#Creating a custom report using ccnet - cruisecontrol.netApache modules installed but don't seem to load on Ubuntu - modulehow to register failures in php module? - phpOpenGL performance when rendering a "virtual gallery" (texture) - performanceC ++ Builder and Excel Automation, where to start? - c ++Way to store dates with missing days / months in mysql (php) - dateShould a student diversify or master programming languages? - programming-languages | fooobar.comHard coding of resources in the application - c ++How can I get the initial value of the identity column in MySql - mysqlAll Articles