Path: csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!goblin1!goblin.stu.neva.ru!news.astraweb.com!border5.a.newsrouter.astraweb.com!feed.xsnews.nl!border-1.ams.xsnews.nl!206.55.64.80.MISMATCH!newspump.sol.net!posts.news.megabitz.net!nnrp3-asbnva.megabitz.net!not-for-mail From: David RF Newsgroups: comp.lang.c.moderated Subject: Re: How to declare a function parameter to be optional? Date: Thu, 10 Feb 2011 21:41:00 -0600 (CST) Organization: http://groups.google.com Sender: clcm@herd.plethora.net Approved: clc@plethora.net Message-ID: References: User-Agent: G2/1.0 Complaints-To: groups-abuse@google.com Return-Path: X-Original-to: clcm@plethora.net X-Old-complaints-to: groups-abuse@google.com Domainkey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=x-authentication-warning:to:path:from:newsgroups:subject:date :organization:lines:message-id:references:nntp-posting-host :mime-version:content-type:content-transfer-encoding:x-trace :x-complaints-to:nntp-posting-date:complaints-to:injection-info :user-agent:x-http-useragent; b=MmiDLJ46yigEsjm8QuQU26oTtN544jXz3C/nAjSAIc9lNeiTeEyK9dQt6qCyd1ASjI atFk0NWqReVdC2E5emFnEk0qyDI5hMuVGhvP10vIc6s4zMjnaNWVRhYLEA4YZdaidBaf dhuwQDtwr+Nv3Oqvb/ccsb+wOTmzxF32JfVgM= Content-Type: text/plain; charset=windows-1252 Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:x-authentication-warning:to:path:from :newsgroups:subject:date:organization:lines:message-id:references :nntp-posting-host:mime-version:content-type :content-transfer-encoding:x-trace:x-complaints-to:nntp-posting-date :complaints-to:injection-info:user-agent:x-http-useragent; bh=5at/azKKx3PZLTgfMcWCvHlNKu8+CxWDEzPztZNUxyU=; b=HQvIUw++hewPqQb9jJOZiNVYPd4J1zBFYnChD84YFrfpZ6FFzFI/7TtPiCyeqOYNMu 6XcX6eUcVO2EPM3nrIpvZsWRi/pUFpfEQwA8THmhKSw+x3QLe9cL7H7Ztn1WfdreWcis 6ftW/bfLqBpWXBH3+Hv93BCX55z1XAHHSJIYY= Mime-Version: 1.0 Delivered-To: clcm@localhost.plethora.net X-Old-trace: posting.google.com 1297333512 11144 127.0.0.1 (10 Feb 2011 10:25:12 GMT) Injection-Info: u6g2000vbh.googlegroups.com; posting-host=213.96.79.9; posting-account=EgE3iwoAAACtMZxGmHnDSqw2wB1ohP_t Content-Transfer-encoding: quoted-printable X-Http-useragent: Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.1.16) Gecko/20110107 Iceweasel/3.5.16 (like Firefox/3.5.16),gzip(gfe) X-Authentication-warning: yws13.prod.google.com: news set sender to news@google.com using -f Lines: 36 NNTP-Posting-Date: 11 Feb 2011 03:41:02 GMT NNTP-Posting-Host: e74dd9a6.news.megabitz.net X-Trace: DXC=I3RbG8Vg;ESFLkgBXIb8]Z><6FU_Q:4mR^W\Y;gN2lO]hB41nPGo12Z?jW6Mmc0=4W7d@DE\31QYUMoRO]O40E3X`H03LY\jMhPXKFlA:i7@2W X-Complaints-To: abuse@megabitz.net Xref: csiph.com comp.lang.c.moderated:508 On 9 feb, 19:22, GilNajera wrote: > Hi! > > On 7 feb, 22:58, Pushkar Prasad wrote: > > > Hello All > > > Is there a way to ensure that one of the function argument is set as > > optional. So that it is not mandatory for the caller to pass that > > parameter and yet if necessary can be used? > > You must set a default value to that parameter when declaring the > function: > > void myFunction(int parameter1, int optional_parameter=3D23); > > All non optional parameters must precede the optional ones. > > So, when you call myFunction using just one parameter, the second will > take the value of 23. > > Hope this helps. > -- > comp.lang.c.moderated - moderation address: c...@plethora.net -- you must > have an appropriate newsgroups line in your header for your mail to be se= en, > or the newsgroup name in square brackets in the subject line. =A0Sorry. void myFunction(int parameter1, int optional_parameter=3D23); expected =91;=92, =91,=92 or =91)=92 before =91=3D=92 token You're probably talking about c++ -- comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must have an appropriate newsgroups line in your header for your mail to be seen, or the newsgroup name in square brackets in the subject line. Sorry.