That's not how C++ works.
You need:
std:: pair<int, int> Car() {
...
return {a, b};
}
auto [a, b] = Car();
std::cout << a << ", " << b;
What you have:
int Car()
Car
is a function which returns 1 int
.
return a, b;
Here you have the comma operator which evaluates every argument and discards all but the last one. So it returns b
.
a, b = Car();
(a, b)
Again the comma operator. a
is discarded and b
is assigned. Then a
is discarded and b
is printed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…