следующее.
                  
                  
                  
                  
                  
                  #include <iostream>
                  
                  
                  
                  
                  
                  using namespace std;
                  
                  
                  
                  
                  
                  // Type your code here, or load an example.
                  
                  
                  struct counter {
                  
                  
                    unsigned cnt;
                  
                  
                    counter():cnt( 0 ) {};
                  
                  
                    counter( unsigned c ):cnt( c ) {};
                  
                  
                    unsigned next() {
                  
                  
                      cnt += 1;
                  
                  
                      return cnt;
                  
                  
                    }
                  
                  
                  };
                  
                  
                  
                  
                  
                  void print_params( unsigned p1, unsigned p2, unsigned p3 ){
                  
                  
                      cout << p1 << " " << p2 << " " << p3 << endl;
                  
                  
                  }
                  
                  
                  
                  
                  
                  int main(){
                  
                  
                      counter t;
                  
                  
                      print_params( t.next(), t.next(), t.next() );
                  
                  
                  }
                  
                  
                  Вывод
                  
                  
                  3 2 1
                  
                  
                  well fuck.
                  
                  
                  
                  
                  
                  Это где-то в стандарте описано?
                  
                  
                
Order of evaluation of any part of any expression, including order of evaluation of function arguments is unspecified https://en.cppreference.com/w/cpp/language/eval_order
Да, в стандарте есть понятие Undefined behavior
Unspecified в данном случае
да, опечатался
Спасибо. Как-то никогда с таким не сталкивался, а тут внезапно.
По теории вероятности 99% отстреливаю себе ноги на этом в первые месяцы обучения С++.
Обсуждают сегодня