Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #88163

Re: Christmas Quiz 2022

From Paavo Helde <eesnimi@osa.pri.ee>
Newsgroups comp.lang.c, comp.lang.c++, free.c
Subject Re: Christmas Quiz 2022
Date 2022-12-21 00:13 +0200
Organization A noiseless patient Spider
Message-ID <tntc2r$ptr7$2@dont-email.me> (permalink)
References <tnnspa$27vkp$1@paganini.bofh.team> <tnt6vc$pgk6$1@dont-email.me> <tntalf$ptr7$1@dont-email.me> <tntb9j$q06h$1@dont-email.me>

Cross-posted to 3 groups.

Show all headers | View raw


21.12.2022 00:00 Andrey Tarasevich kirjutas:
> On 12/20/2022 1:49 PM, Paavo Helde wrote:
>> 20.12.2022 22:46 Andrey Tarasevich kirjutas:
>>
>>>> 4) What is the difference between x = y++; and x = ++y;?
>>>
>>> Quite possibly, none. There's no reason to believe this code has any 
>>> observable behavior.
>>
>> I guess he got you there. The value of x is observable. Too 
>> well-defined question?
> 
> I don't know what you are trying to say by "the value of x is 
> observable", but let me reiterate: there's no reason to believe this 
> code has any observable behavior. (Feel free to look up the definition.) 
> Let alone the fact that in C++ it has no specific semantics at all.

The questions were cross-posted to C so I'm assuming int.

#include <iostream>

void f1() {
	int y = 0;
	int x = y++;
	std::cout << "x = " << x << "\n";
}

void f2() {
	int y = 0;
	int x = ++y;
	std::cout << "x = " << x << "\n";
}

int main() {
	f1();
	f2();
}

Output:

x = 0
x = 1

Different enough?



Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Christmas Quiz 2022 Roman P <invalid@example.com> - 2022-12-18 20:00 +0000
  Re: Christmas Quiz 2022 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-18 21:22 +0000
  Re: Christmas Quiz 2022 red floyd <no.spam.here@its.invalid> - 2022-12-18 13:36 -0800
  Re: Christmas Quiz 2022 "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-12-18 13:48 -0800
    Re: Christmas Quiz 2022 Siri Cruise <chine.bleu@yahoo.com> - 2022-12-18 14:57 -0800
      Re: Christmas Quiz 2022 "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-12-18 15:43 -0800
        Re: Christmas Quiz 2022 Lynn McGuire <lynnmcguire5@gmail.com> - 2022-12-19 23:40 -0600
      Re: Christmas Quiz 2022 "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-12-20 14:01 -0800
  Re: Christmas Quiz 2022 "daniel...@gmail.com" <danielaparker@gmail.com> - 2022-12-18 15:18 -0800
  Re: Christmas Quiz 2022 Kaz Kylheku <864-117-4973@kylheku.com> - 2022-12-20 13:49 +0000
    Re: Christmas Quiz 2022 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-20 14:33 +0000
      Re: Christmas Quiz 2022 Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-12-20 14:44 +0000
  Re: Christmas Quiz 2022 Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-12-20 12:46 -0800
    Re: Christmas Quiz 2022 Paavo Helde <eesnimi@osa.pri.ee> - 2022-12-20 23:49 +0200
      Re: Christmas Quiz 2022 Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-12-20 14:00 -0800
        Re: Christmas Quiz 2022 Paavo Helde <eesnimi@osa.pri.ee> - 2022-12-21 00:13 +0200
          Re: Christmas Quiz 2022 Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-12-20 14:38 -0800
    Re: Christmas Quiz 2022 Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-12-20 21:31 -0800
      Re: Christmas Quiz 2022 David Brown <david.brown@hesbynett.no> - 2022-12-21 12:02 +0100

csiph-web