I tried to do something like this:
int& g(int& number = 0) { //maybe do something with number return number; }
but that will not work. It must be passed by reference. Thanks for any help.
PS I think that “related questions” appear after you type “Heading”, this is a good idea, but I also think that they should only be displayed if they are related to a certain language, that is, for me less than useless to search for a topic with a similar problem but in Ruby.
If you really want to do this:
:
// header const int & g( const int & number = 0 ); // implementation const int & g( const int & number ) { //maybe do something with number return number; }
PS , SO Meta, ( ), , , STILL .
, , referand. 0.
, ?
().
, , , ( ): k = g(k);
k = g(k);
, , " " , :
int& g(int&); int g() { int arg = 0; return g(arg); }
.
- , , . , : , ?
- , returnvalue? , , . - " ", " ".
int g(int& arg) { int oldarg( arg ); // maybe modify arg // return old value of arg return oldarg; }
const int& g(int& arg) { static int accumulator; accumulator += arg; return accumulator; }
/ .
, .
Source: https://habr.com/ru/post/1725601/More articles:Is there a nosql repository that also maintains relationships between stored objects? - google-app-engineHow to transfer a shared object to an Aspx - generics pagePython: количество времени на стене, в течение которого выполнялся процесс - pythonHow to connect GWT to CometD / Bayeux events? - dojoкак получить содержимое внутри div вместе со всеми тегами html вместе со значениями, присутствующими в текстовом поле и т.д. - javascriptTesting User.IsInRole in MVC.NET - unit-testingWhere is the localhost development locator for the gae java sdk / eclipse plugin? - javateamcity launches several build projects with revision - buildSilverlight - snapping to control border - silverlightButton template does not display image clearly - imageAll Articles