From: Yorgos Pagles <pagles@intralot.com>
To: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: Re: Need for const in function argument list
Date: Mon, 27 Mar 2006 11:25:41 +0300 [thread overview]
Message-ID: <4427A185.4080306@intralot.com> (raw)
In-Reply-To: <17446.49419.665743.127524@cerise.gclements.plus.com>
Glynn Clements wrote:
>
> If a pointer parameter is declared as const, you can pass either const
> or non-const pointers. If it isn't declared as const, then you can
> only pass non-const pointers, not const pointers.
>
For that alone please use const when it is needed. Some moron I had to
work with once wrote a wrapper for some printing functions and in the
most significant of his functions he had
void PrintText(char*){/...}
and there was no way for me to write:
PrintText("Hello World");
in my code, I had to use the ugly:
PrintText(const_cast<char*>("Hello World"));
because of someone else's ignorance.
--
Make it work. Make it fast. Make it right. Pick any two...
prev parent reply other threads:[~2006-03-27 8:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-26 10:44 Need for const in function argument list Shriramana Sharma
2006-03-26 10:57 ` Steve Graegert
2006-03-26 13:38 ` Shriramana Sharma
2006-03-26 15:38 ` Steve Graegert
2006-03-26 16:27 ` Glynn Clements
2006-03-27 8:25 ` Yorgos Pagles [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4427A185.4080306@intralot.com \
--to=pagles@intralot.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.