From c904f740b7f41b6541f116e8cde5d50f400c943e Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Mon, 15 Aug 2022 12:49:34 +0100 Subject: [PATCH] Value of variables in expression order guaranteed. --- main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 359256d..73ff9c6 100644 --- a/main.cpp +++ b/main.cpp @@ -11,6 +11,11 @@ int getValue() int main() { - std::cout << getValue() + (getValue() * getValue()); // a + (b * c) + int a{ getValue() }; + int b{ getValue() }; + int c{ getValue() }; + + std::cout << a + (b * c); // order of eval doesn't matter now + return 0; }