LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-26-2011, 11:32 PM   #1
chinho
Member
 
Registered: Dec 2010
Distribution: fedora, openSUSE
Posts: 49

Rep: Reputation: 1
Question about function default parameter in C++


Hi guys,

Say, I have the below function header (with default parameter) in c++

Code:
void myfunc(int a, int b=10, int c=5, int d);
How shall I call myfunc, if......

Quote:
1. If i do not wan to specify param b and c
2. If i do not wan to specify param c
Please help. Cheers,
Chinho
 
Old 01-26-2011, 11:55 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hint - any argument that has a default needs to be *last*.

For example:
Quote:
http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx

Default arguments are used only in function calls where trailing arguments are omitted — they must be the last argument(s). Therefore, the following code is illegal:
Code:
int print( double dvalue = 0.0, int prec );
PS:
Does "Chinho" have anything to do with "Hawaii Five-0"? Either the old series, or the new one?

Last edited by paulsm4; 01-27-2011 at 12:00 AM.
 
Old 01-27-2011, 12:52 AM   #3
chinho
Member
 
Registered: Dec 2010
Distribution: fedora, openSUSE
Posts: 49

Original Poster
Rep: Reputation: 1
Thanks paulsm4.

Nope! Chinho is my name

Cheers,
Chinho
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
function parameter vbx_wx Programming 5 04-04-2010 03:34 PM
Compilation issue when Function is parameter in function call on LINUX sa20358 Linux - Software 2 07-24-2008 11:19 PM
what is function parameter? Jeon, Chang-Min Linux - Software 2 06-22-2006 07:53 PM
C: struct as a function parameter zokik Programming 3 12-06-2003 03:52 PM
Bash function parameter Misel Programming 2 05-17-2003 12:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration