Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / How to set the function of the arguement is optional?

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. How to set the function of the arguement is optional?
#3105
Posted by: mooncake 2003-12-18 23:10:21
For example:

wxString aaa(wxString b) {

}

b is a optional arguement, it can be?

Thank you.
Meow~
Message2. Re: How to set the function of the arguement is optional?
#3107
Posted by: upCASE 2003-12-19 05:51:43
Hi!
When definnig the prototype for that function use a default argument like
wxString somefunc(wxString b = "");
You don't need to repeat defaults in the implementation of the function.

Another way would be to overload the function so that there is
wxString somefunc();
and
wxString somefunc(wxString b);

You could also use an argument list of variable length, going from 0 to n. But I guess you don't want that...

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: How to set the function of the arguement is optional?
#3111
Posted by: mooncake 2003-12-19 20:04:51
Oic... it quite similar with PHP...

Thank you.. :P

Meow~
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-12-14  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0