What is a temporary distribution?

In C ++, what is temporary allocation and when is it used? Is there such a thing? This was mentioned in the TA course notes, but I could not find any information about it ...

+3
source share
2 answers

When people say "temporary", they often refer to rvalues. These are objects created and not tied to the variable name, therefore they do not live outside the current statement. IE:

int foo()
{
     Do( Object() );
}

The created object () is the value of r that you can hear, called temporary.

+3
source

I suspect that your TA could refer to objects without the name created during the evaluation of the expression.

SomeClass x(1), y(2), z(3);
SomeClass t = x + y + z;

x + y + z operator+() ; ( t).

+2

Source: https://habr.com/ru/post/1756197/


All Articles