Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #82378
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c++, comp.lang.c |
| Subject | Re: Does this program have the specified behavior? |
| Date | 2021-11-18 11:15 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <874k89ogte.fsf@bsb.me.uk> (permalink) |
| References | (1 earlier) <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <536lJ.49729$JZ3.33398@fx05.iad> <dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com> <sn4s2o$tke$1@gioia.aioe.org> |
Cross-posted to 2 groups.
Juha Nieminen <nospam@thanks.invalid> writes:
> In comp.lang.c++ olcott <NoOne@nowhere.com> wrote:
>>>> typedef int (*ptr)();
>>>>
>>>> int H(ptr x, ptr y)
>>>> {
>>>> x(y); // direct execution of P(P)
>>>> return 1;
>>>> }
>>
>> This code does compile and run correctly.
>
> It might compile as C, but it shouldn't compile as C++, because it's trying
> to call an int(*)() with a parameter, even though that function (that the
> pointer is pointing to does not take any parameter.)
Just as it must not compile in C++, this code must compile in C. The
meaning of empty ()s in a function declaration is different between the
two languages.
When I tidied up the code, I wrote C, not C++, because C has a more
suitable type available.
--
Ben.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Do this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-16 21:33 -0600
Re: Do this program have the specified behavior? wij <wyniijj@gmail.com> - 2021-11-16 20:10 -0800
Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-16 22:46 -0600
Re: Does this program have the specified behavior? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-11-16 21:12 -0800
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-17 08:33 -0600
Re: Does this program have the specified behavior? Richard Damon <Richard@Damon-Family.org> - 2021-11-17 06:53 -0500
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-17 08:49 -0600
Re: Does this program have the specified behavior? Juha Nieminen <nospam@thanks.invalid> - 2021-11-18 06:32 +0000
Re: Does this program have the specified behavior? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-18 11:15 +0000
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-18 08:59 -0600
Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-18 08:58 -0600
Re: Does this program have the specified behavior? Anurag Ranjan <anuragranjan630@gmail.com> - 2021-11-17 22:00 +0000
csiph-web