 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jonathan Mcdougall Guest
|
Posted: Mon Oct 06, 2003 7:23 am Post subject: Re: void and this |
|
|
| Quote: | I have a class member function declared as
class some_class {
...
virtual int call(void);
|
void in an empty parameter list is considered bad style in C++.
| Quote: | };
Can I use this-> inside the function body?
|
Of course, what makes you think you can't?
Jonathan
|
|
| Back to top |
|
 |
Vladimir Grul Guest
|
Posted: Mon Oct 06, 2003 7:28 am Post subject: void and this |
|
|
Hello,
I have a class member function declared as
class some_class {
....
virtual int call(void);
};
Can I use this-> inside the function body?
Thanks.
Vladimir
|
|
| Back to top |
|
 |
Attila Feher Guest
|
Posted: Mon Oct 06, 2003 7:38 am Post subject: Re: void and this |
|
|
Vladimir Grul wrote:
| Quote: | Hello,
I have a class member function declared as
class some_class {
...
virtual int call(void);
|
Drop the void. C++ is not C.
virtual int call(void);
and
virtual int call();
mean exactly the same
| Quote: | };
Can I use this-> inside the function body?
|
Yes.
--
Attila aka WW
|
|
| Back to top |
|
 |
Vladimir Grul Guest
|
Posted: Mon Oct 06, 2003 8:35 am Post subject: Re: void and this |
|
|
"Jonathan Mcdougall" <jonathanmcdougall (AT) DELyahoo (DOT) ca> writes:
| Quote: |
Of course, what makes you think you can't?
|
I was not sure if there is an implicit this in parameter list.
Thank you and Attila.
Vladimir
|
|
| Back to top |
|
 |
David B. Held Guest
|
Posted: Mon Oct 06, 2003 8:51 am Post subject: Re: void and this |
|
|
"Jonathan Mcdougall" <jonathanmcdougall (AT) DELyahoo (DOT) ca> wrote
| Quote: | I have a class member function declared as
class some_class {
...
virtual int call(void);
void in an empty parameter list is considered bad style in C++.
[...]
|
Since when?
Dave
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
|
|
| Back to top |
|
 |
David B. Held Guest
|
Posted: Mon Oct 06, 2003 8:52 am Post subject: Re: void and this |
|
|
"Attila Feher" <attila.feher (AT) lmf (DOT) ericsson.se> wrote
| Quote: | Vladimir Grul wrote:
Hello,
I have a class member function declared as
class some_class {
...
virtual int call(void);
Drop the void. C++ is not C.
virtual int call(void);
and
virtual int call();
mean exactly the same
[...]
|
So why does "(void)" mean "C"?
Dave
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
|
|
| Back to top |
|
 |
John Carson Guest
|
Posted: Mon Oct 06, 2003 9:27 am Post subject: Re: void and this |
|
|
"David B. Held" <dheld (AT) codelogicconsulting (DOT) com> wrote
| Quote: | "Attila Feher" <attila.feher (AT) lmf (DOT) ericsson.se> wrote in message
news:blr63n$be7$1 (AT) newstree (DOT) wise.edt.ericsson.se...
Vladimir Grul wrote:
Hello,
I have a class member function declared as
class some_class {
...
virtual int call(void);
Drop the void. C++ is not C.
virtual int call(void);
and
virtual int call();
mean exactly the same
[...]
So why does "(void)" mean "C"?
Dave
|
If memory serves, in the C language, foo(void) means no arguments, whereas
foo() can mean none or one or ... any number of arguments. In C++, by
contrast, both foo(void) and foo() mean no arguments. Thus the void is
redundant in C++ but meaningful in C.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
|
|
| Back to top |
|
 |
Attila Feher Guest
|
Posted: Mon Oct 06, 2003 9:33 am Post subject: Re: void and this |
|
|
David B. Held wrote:
| Quote: | Drop the void. C++ is not C.
virtual int call(void);
and
virtual int call();
mean exactly the same
[...]
So why does "(void)" mean "C"?
|
So why do you have to pick a quarrel on everything? Have you been bitten by
some vendetta bug?
To the OP:
As I have said above: the void is redundant, and has absolutely no effect on
a conforming compiler. And as everything redundant adding no value, the
only thing it can add is error, misunderstanding, misleading, wondering
collegagues why is it there and so forth. Since a virtual member function
needs no portability between C and C++ and the void there adds no value, it
is better be left out.
--
Attila aka WW
|
|
| Back to top |
|
 |
jeffc Guest
|
Posted: Mon Oct 06, 2003 3:30 pm Post subject: Re: void and this |
|
|
"Attila Feher" <attila.feher (AT) lmf (DOT) ericsson.se> wrote
| Quote: | So why do you have to pick a quarrel on everything?
|
bwahahahaahahaha
| Quote: | As I have said above: the void is redundant, and has absolutely no effect
on
a conforming compiler. And as everything redundant adding no value, the
only thing it can add is error, misunderstanding, misleading, wondering
collegagues why is it there and so forth.
|
Ridiculous. What POSSIBLE "misunderstanding" can come from putting the void
in there? It's no more "misleading" than the "public" here
struct A
{
public:
int i;
};
or the "private" here
class A
{
private:
int i;
};
Or the parentheses here
i = a + (b * c)
|
|
| Back to top |
|
 |
WW Guest
|
Posted: Mon Oct 06, 2003 3:37 pm Post subject: Re: void and this |
|
|
jeffc wrote:
| Quote: | "Attila Feher" <attila.feher (AT) lmf (DOT) ericsson.se> wrote in message
news:blrcse$g6e$1 (AT) newstree (DOT) wise.edt.ericsson.se...
So why do you have to pick a quarrel on everything?
bwahahahaahahaha
|
Stop trolling please.
--
WW aka Attila
|
|
| Back to top |
|
 |
Jerry Coffin Guest
|
Posted: Mon Oct 06, 2003 4:00 pm Post subject: Re: void and this |
|
|
In article <j933ovcm7c19t5sikqugb3dhmk9dtqk7tp (AT) 4ax (DOT) com>,
[email]tom_usenet (AT) hotmail (DOT) com[/email] says...
[ ... ]
| Quote: | Dennis Ritchie and Doug Ilroy
|
Doug McIlroy perhaps?
--
Later,
Jerry.
The universe is a figment of its own imagination.
|
|
| Back to top |
|
 |
tom_usenet Guest
|
Posted: Mon Oct 06, 2003 4:01 pm Post subject: Re: void and this |
|
|
On Mon, 6 Oct 2003 03:51:58 -0500, "David B. Held"
<dheld (AT) codelogicconsulting (DOT) com> wrote:
| Quote: | "Jonathan Mcdougall" <jonathanmcdougall (AT) DELyahoo (DOT) ca> wrote in message
news:D69gb.32006$ti3.513467 (AT) wagner (DOT) videotron.net...
I have a class member function declared as
class some_class {
...
virtual int call(void);
void in an empty parameter list is considered bad style in C++.
[...]
Since when?
|
Dennis Ritchie and Doug Ilroy described use of void to represent an
empty parameter list in C as an "abomination". Stroustrup agrees with
them, and void f(void); was illegal syntax in the early days of C++.
However it was reincorporated into C++ when C89 decided to use that
syntax in the interests of compatibility.
Tom
|
|
| Back to top |
|
 |
tom_usenet Guest
|
Posted: Mon Oct 06, 2003 4:09 pm Post subject: Re: void and this |
|
|
On Mon, 06 Oct 2003 16:00:52 GMT, Jerry Coffin <jcoffin (AT) taeus (DOT) com>
wrote:
| Quote: | In article <j933ovcm7c19t5sikqugb3dhmk9dtqk7tp (AT) 4ax (DOT) com>,
[email]tom_usenet (AT) hotmail (DOT) com[/email] says...
[ ... ]
Dennis Ritchie and Doug Ilroy
Doug McIlroy perhaps?
|
Er, yes. Whoops.
Tom
|
|
| Back to top |
|
 |
Kevin Goodsell Guest
|
Posted: Mon Oct 06, 2003 6:08 pm Post subject: Re: void and this |
|
|
John Carson wrote:
| Quote: |
If memory serves, in the C language, foo(void) means no arguments, whereas
foo() can mean none or one or ... any number of arguments.
|
Actually, it means there is a fixed, but unspecified number of
arguments. You still have to pass exactly the right number and type of
arguments, but the compiler is unable to check whether you did. It's a
relic from before prototypes existed in C.
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
|
|
| Back to top |
|
 |
David B. Held Guest
|
Posted: Mon Oct 06, 2003 6:21 pm Post subject: Re: void and this |
|
|
"John Carson" <donaldquixote (AT) datafast (DOT) net.au> wrote
| Quote: | [...]
If memory serves, in the C language, foo(void) means no
arguments, whereas foo() can mean none or one or ... any
number of arguments. In C++, by contrast, both foo(void)
and foo() mean no arguments. Thus the void is redundant
in C++ but meaningful in C.
|
I understand the distinction and the history, but I still fail to
understand why (void) is frowned upon or viewed as "C".
I happen to like the explicit way in which it says "this function
takes no arguments".
Dave
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|