Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #15126
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: Any way to defer template function overloading? |
| Date | Mon, 02 Apr 2012 17:53:43 +1200 |
| Lines | 47 |
| Message-ID | <9tst77FfaaU3@mid.individual.net> (permalink) |
| References | <jl8d4h$hbf$1@speranza.aioe.org> <4f788f56$0$4347$7b1e8fa0@news.nbl.fi> <jlbekq$693$1@speranza.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net v/KAp7N5mVbI0S8L3wnGiw/zMCiYct9v54LuelFPWKpzcJqwyZ |
| Cancel-Lock | sha1:qv218LwOKJBTn8bWCZnqE6R239E= |
| User-Agent | Mozilla/5.0 (X11; SunOS i86pc; rv:7.0.1) Gecko/20111228 Thunderbird/7.0.1 |
| In-Reply-To | <jlbekq$693$1@speranza.aioe.org> |
| Xref | csiph.com comp.lang.c++:15126 |
Show key headers only | View raw
On 04/ 2/12 05:48 PM, Qi wrote:
> On 2012-4-2 1:24, Juha Nieminen wrote:
>> Qi<no@no.no> wrote:
>>> int main(int argc, char * argv[])
>>> {
>>> (void)argc;
>>> (void)argv;
>>
>> This seemed like nonsensical code because it does nothing. Then I realized
>> that it's an ugly hack to silence the compiler warning about unused
>> variables. That's not how you do it.
>
> Ugly? Maybe.
> But it makes a lot of sense to me.
>
> There is time that some parameters are not used. Such as implementing
> an interface, and the interface function just has extra parameters for
> flexibility.
>
> Though I can write "int main(int, char **)", I won't do it because
> I expect others may read my code and feel difficult to understand
> the function without the parameter name.
Then why don't you just write "int main()"?
> For example,
> int findSomeThing(int, int); // what's that? Don't know
> int findSomeThing(int beginIndex, int endIndex); // oh, find between
> // beginIndex, endIndex, but the function doesn't use them.
>
> Of course we can put the parameter name to declaration and omit
> in the definition, but then the reader needs to dig into the header
> only for parameters when he is reading the source code.
If the parameter isn't used (and named), why would the reader look for it?
> int main(int /*argc*/, char** /*argv*/) ?
> To me, it's more ugly and easier to misread than (void)argc.
> **? */? How may * and / there in one line?
>
> And I think "(void)argc" is well known for C++ developers, maybe
> I'm wrong?
Maybe, most people I know simply omit the name.
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Any way to defer template function overloading? Qi <no@no.no> - 2012-04-01 10:05 +0800
Re: Any way to defer template function overloading? Ian Collins <ian-news@hotmail.com> - 2012-04-01 16:06 +1200
Re: Any way to defer template function overloading? Qi <no@no.no> - 2012-04-01 13:53 +0800
Re: Any way to defer template function overloading? Juha Nieminen <nospam@thanks.invalid> - 2012-04-01 17:24 +0000
Re: Any way to defer template function overloading? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-02 00:40 +0200
Re: Any way to defer template function overloading? Ian Collins <ian-news@hotmail.com> - 2012-04-02 11:02 +1200
Re: Any way to defer template function overloading? Juha Nieminen <nospam@thanks.invalid> - 2012-04-02 05:29 +0000
Re: Any way to defer template function overloading? Qi <no@no.com> - 2012-04-02 13:48 +0800
Re: Any way to defer template function overloading? Ian Collins <ian-news@hotmail.com> - 2012-04-02 17:53 +1200
Re: Any way to defer template function overloading? Qi <no@no.com> - 2012-04-02 13:57 +0800
Re: Any way to defer template function overloading? Ian Collins <ian-news@hotmail.com> - 2012-04-02 18:12 +1200
Re: Any way to defer template function overloading? Miles Bader <miles@gnu.org> - 2012-04-02 15:32 +0900
Re: Any way to defer template function overloading? Miles Bader <miles@gnu.org> - 2012-04-02 14:58 +0900
Re: Any way to defer template function overloading? Juha Nieminen <nospam@thanks.invalid> - 2012-04-02 10:11 +0000
Re: Any way to defer template function overloading? Qi <no@no.com> - 2012-04-02 19:04 +0800
Re: Any way to defer template function overloading? Qi <no@no.com> - 2012-04-02 19:17 +0800
Re: Any way to defer template function overloading? jgk@panix.com (Joe keane) - 2012-04-02 14:41 +0000
csiph-web