C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: void ErrorMessage(int,int) const

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Phlip
Guest





PostPosted: Sat Sep 27, 2003 6:12 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote



Gary wrote:

Quote:
I read the prototype as:
return type is void, function name is ErrorMessage.
The parameters are unusual, I don't know how to refer to those
unreferenced parameters.

Are you writing the function or calling it?

Quote:
As for const, does that mean that the function is unchangeable?

Were that function a member of a class, the secret 'this' pointer would
point to a constant object. That means you can't change any members of the
object, or call any member function that is not 'const'.

I cross-posted to the newsgroup where this question belongs.

--
Phlip
http://www.c2.com/cgi/wiki?TestFirstUserInterfaces



Back to top
Jack Klein
Guest





PostPosted: Sun Sep 28, 2003 2:11 am    Post subject: Re: void ErrorMessage(int,int) const Reply with quote



On Sat, 27 Sep 2003 18:12:12 GMT, "Phlip" <phlip_cpp (AT) yahoo (DOT) com> wrote
in comp.programming:

Quote:
Gary wrote:

I read the prototype as:
return type is void, function name is ErrorMessage.
The parameters are unusual, I don't know how to refer to those
unreferenced parameters.

Are you writing the function or calling it?

As for const, does that mean that the function is unchangeable?

Were that function a member of a class, the secret 'this' pointer would
point to a constant object. That means you can't change any members of the
object, or call any member function that is not 'const'.

I cross-posted to the newsgroup where this question belongs.

It's not a secret, honest. Everybody programming in C++ for more than
a week or so knows it's there.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq

Back to top
Gary
Guest





PostPosted: Sun Sep 28, 2003 2:04 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote



Jack Klein <jackklein (AT) spamcop (DOT) net> wrote

Quote:
On Sat, 27 Sep 2003 18:12:12 GMT, "Phlip" <phlip_cpp (AT) yahoo (DOT) com> wrote
in comp.programming:

Gary wrote:

I read the prototype as:
return type is void, function name is ErrorMessage.
The parameters are unusual, I don't know how to refer to those
unreferenced parameters.

Are you writing the function or calling it?

As for const, does that mean that the function is unchangeable?

Were that function a member of a class, the secret 'this' pointer would
point to a constant object. That means you can't change any members of the
object, or call any member function that is not 'const'.

I cross-posted to the newsgroup where this question belongs.

It's not a secret, honest. Everybody programming in C++ for more than
a week or so knows it's there.

I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

Regards.

Gary

Back to top
Mike Wahler
Guest





PostPosted: Sun Sep 28, 2003 4:59 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote


"Gary" <gjc888 (AT) hotmail (DOT) com> wrote

Quote:
Jack Klein <jackklein (AT) spamcop (DOT) net> wrote

On Sat, 27 Sep 2003 18:12:12 GMT, "Phlip" <phlip_cpp (AT) yahoo (DOT) com> wrote
in comp.programming:

Gary wrote:

I read the prototype as:
return type is void, function name is ErrorMessage.
The parameters are unusual, I don't know how to refer to those
unreferenced parameters.

Are you writing the function or calling it?

As for const, does that mean that the function is unchangeable?

Were that function a member of a class, the secret 'this' pointer
would
point to a constant object. That means you can't change any members of
the
object, or call any member function that is not 'const'.

I cross-posted to the newsgroup where this question belongs.

It's not a secret, honest. Everybody programming in C++ for more than
a week or so knows it's there.

I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

A prototype only needs the type names, but many folks
add identifiers as well for documentation purposes.

In a function, if you want to refer to the parameters
then of course they'll need identifiers.

Why do you "hope there's another way"? What prevents
you from giving identifiers to your paramters?

int foo(int, int); // prototype

int foo(int arg1, int )
{
cout << arg1;
// cant get at second arg, no identifier
}

-Mike



Back to top
Joe Wright
Guest





PostPosted: Sun Sep 28, 2003 5:16 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote

Gary wrote:
Quote:

Jack Klein <jackklein (AT) spamcop (DOT) net> wrote

On Sat, 27 Sep 2003 18:12:12 GMT, "Phlip" <phlip_cpp (AT) yahoo (DOT) com> wrote
in comp.programming:

Gary wrote:

I read the prototype as:
return type is void, function name is ErrorMessage.
The parameters are unusual, I don't know how to refer to those
unreferenced parameters.

Are you writing the function or calling it?

As for const, does that mean that the function is unchangeable?

Were that function a member of a class, the secret 'this' pointer would
point to a constant object. That means you can't change any members of the
object, or call any member function that is not 'const'.

I cross-posted to the newsgroup where this question belongs.

It's not a secret, honest. Everybody programming in C++ for more than
a week or so knows it's there.

I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

Regards.

Gary

The function itself requires named parameters but the prototype doesn't
care. It only needs the type or the parameters. Naming parameters in
prototypes is only a clue to the reader, not the compiler, about what
the parameter might be.

The reason for the prototype is to 'warn' the compiler that you plan to
call a particular function so that the compiler might check that you
call the function correctly and perhaps even convert the type of your
given parameter to the type the function expects. For example, when you
include math.h you get a prototype for the pow function which looks
something like..

double pow(double _x, double _y); /* names of the parameters are not
required */

In your program you might have something like..

int p;
p = pow(2,3);

...and the compiler knows how to handle everything and p == 8.
--
Joe Wright mailto:joewwright (AT) earthlink (DOT) net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---

Back to top
Kevin Goodsell
Guest





PostPosted: Sun Sep 28, 2003 6:37 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote

Joe Wright wrote:

Quote:
Gary wrote:


I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

Regards.

Gary


The function itself requires named parameters

Well, only if you want to use them. You're free to leave off the names,
but then you have no way to refer to the parameter.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.


Back to top
Gary
Guest





PostPosted: Sun Sep 28, 2003 10:34 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote

Joe Wright <joewwright (AT) earthlink (DOT) net> wrote

Quote:
Gary wrote:

Jack Klein <jackklein (AT) spamcop (DOT) net> wrote

On Sat, 27 Sep 2003 18:12:12 GMT, "Phlip" <phlip_cpp (AT) yahoo (DOT) com> wrote
in comp.programming:

Gary wrote:

I read the prototype as:
return type is void, function name is ErrorMessage.
The parameters are unusual, I don't know how to refer to those
unreferenced parameters.

Are you writing the function or calling it?

As for const, does that mean that the function is unchangeable?

Were that function a member of a class, the secret 'this' pointer would
point to a constant object. That means you can't change any members of the
object, or call any member function that is not 'const'.

I cross-posted to the newsgroup where this question belongs.

It's not a secret, honest. Everybody programming in C++ for more than
a week or so knows it's there.

I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

Regards.

Gary

The function itself requires named parameters but the prototype doesn't
care. It only needs the type or the parameters. Naming parameters in
prototypes is only a clue to the reader, not the compiler, about what
the parameter might be.

The reason for the prototype is to 'warn' the compiler that you plan to
call a particular function so that the compiler might check that you
call the function correctly and perhaps even convert the type of your
given parameter to the type the function expects. For example, when you
include math.h you get a prototype for the pow function which looks
something like..

double pow(double _x, double _y); /* names of the parameters are not
required */

In your program you might have something like..

int p;
p = pow(2,3);

..and the compiler knows how to handle everything and p == 8.

Thank you for your prompt response.
I agree that calling the function, or writing the prototype, and
passing the parameters do not require the name of the parameter.
However, I'm writing the function. Is it possible to write a function
body without having parameter names?

Regards. Gary

Back to top
Gary
Guest





PostPosted: Sun Sep 28, 2003 10:36 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote

Kevin Goodsell <usenet1.spamfree.fusion (AT) neverbox (DOT) com> wrote

Quote:
Joe Wright wrote:

Gary wrote:


I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

Regards.

Gary


The function itself requires named parameters

Well, only if you want to use them. You're free to leave off the names,
but then you have no way to refer to the parameter.

-Kevin

So no way at all huh? Not even with function pointers ?

Regards.

Gary

Back to top
Mike Wahler
Guest





PostPosted: Sun Sep 28, 2003 10:42 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote


"Gary" <gjc888 (AT) hotmail (DOT) com> wrote

Quote:
Joe Wright <joewwright (AT) earthlink (DOT) net> wrote

Gary wrote:

Jack Klein <jackklein (AT) spamcop (DOT) net> wrote

On Sat, 27 Sep 2003 18:12:12 GMT, "Phlip" wrote
in comp.programming:

Gary wrote:

I read the prototype as:
return type is void, function name is ErrorMessage.
The parameters are unusual, I don't know how to refer to those
unreferenced parameters.

Are you writing the function or calling it?

As for const, does that mean that the function is unchangeable?

Were that function a member of a class, the secret 'this' pointer
would
point to a constant object. That means you can't change any
members of the
object, or call any member function that is not 'const'.

I cross-posted to the newsgroup where this question belongs.

It's not a secret, honest. Everybody programming in C++ for more
than
a week or so knows it's there.

I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

Regards.

Gary

The function itself requires named parameters but the prototype doesn't
care. It only needs the type or the parameters. Naming parameters in
prototypes is only a clue to the reader, not the compiler, about what
the parameter might be.

The reason for the prototype is to 'warn' the compiler that you plan to
call a particular function so that the compiler might check that you
call the function correctly and perhaps even convert the type of your
given parameter to the type the function expects. For example, when you
include math.h you get a prototype for the pow function which looks
something like..

double pow(double _x, double _y); /* names of the parameters are not
required */

In your program you might have something like..

int p;
p = pow(2,3);

..and the compiler knows how to handle everything and p == 8.

Thank you for your prompt response.
I agree that calling the function, or writing the prototype, and
passing the parameters do not require the name of the parameter.
However, I'm writing the function. Is it possible to write a function
body without having parameter names?

Of course, but your function will not have
access to them.

-Mike



Back to top
Mike Wahler
Guest





PostPosted: Sun Sep 28, 2003 10:44 pm    Post subject: Re: void ErrorMessage(int,int) const Reply with quote


"Gary" <gjc888 (AT) hotmail (DOT) com> wrote

Quote:
Kevin Goodsell <usenet1.spamfree.fusion (AT) neverbox (DOT) com> wrote

Joe Wright wrote:

Gary wrote:


I'm writing the function. A prototype was provided, and I need to
figure out to reference the parameters. Until now, I thought you
requried variable names, but I'm hoping there's another way.

Regards.

Gary


The function itself requires named parameters

Well, only if you want to use them. You're free to leave off the names,
but then you have no way to refer to the parameter.

-Kevin

So no way at all huh?

No. Why do you want/need to do that?

Quote:
Not even with function pointers ?

A 'function pointer' is a pointer to a function.
You can invoke a function via a function pointer,
but that does not do anything 'special' with
its parameters.

-Mike



Back to top
Kevin Goodsell
Guest





PostPosted: Mon Sep 29, 2003 12:19 am    Post subject: Re: void ErrorMessage(int,int) const Reply with quote

Gary wrote:


Quote:

Thank you for your prompt response.

Please trim when replying. No need to quote hundreds of lines of
irrelevant text.

Quote:
I agree that calling the function, or writing the prototype, and
passing the parameters do not require the name of the parameter.
However, I'm writing the function. Is it possible to write a function
body without having parameter names?

You don't have to give names to the parameters, but names are the only
way of referring to the parameters, so if you give no names you have no
access:

void foo(int)
{
cout << "This is foo. But I don't know what"
"value you passed to me." << endl;
}

Your situation is puzzling. Why would you not want to give your
parameters names?

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.