Qt - Is this a pass by reference?

If we write the following in Qtas an argument to a function:QString &tableName

Does this mean that we are passing the link?

Thank.

+3
source share
4 answers

Strictly speaking, this is a function parameter, not a function argument. A parameter is a variable declared inside a list of function parameters; the argument is the value passed to the function by the calling function. Therefore, the parameter QString &tableNameis passed by reference. But as an argument to the function &tableNamewill mean "address tableName".

Updated: As requested, here is a sample code to clarify the differences:

void f (double y) ;
f (99.0) ;

double y- parameter declaration; it looks like a variable declaration. yis a function parameter.

99.0 ; , double.

+6

, ++. QString const & tableName, .

+5

. : const, , .

+4

, , Qt, QString - , " ". , , , , , const ( Qt).

+2

All Articles