User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,233 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,778 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1037 | Replies: 4 | Solved
Reply
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

what does func(int x, int y, int z=1) mean?

  #1  
Nov 7th, 2007
what does it mean when you say z=1? Does it ignore what value you pass into the function? What is this called?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: South Dakota
Posts: 981
Reputation: vmanes is a jewel in the rough vmanes is a jewel in the rough vmanes is a jewel in the rough vmanes is a jewel in the rough 
Rep Power: 6
Solved Threads: 97
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Shark

Re: what does func(int x, int y, int z=1) mean?

  #2  
Nov 7th, 2007
That is a default value for z. Thus, you can call the function with just two arguments, and z will be assigned the value 1. If a third argument is passed to the function, z will be assigned that value.

Val
I am in mourning for my country.
Reply With Quote  
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: what does func(int x, int y, int z=1) mean?

  #3  
Nov 7th, 2007
aah thanks, so it's kinda of like overloading without actually overloading!
Reply With Quote  
Join Date: Oct 2007
Posts: 19
Reputation: siddhant3s is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
siddhant3s siddhant3s is offline Offline
Newbie Poster

Re: what does func(int x, int y, int z=1) mean?

  #4  
Nov 7th, 2007
Actually it is not function overloading. In Function overloading the return type and argument type is often different. It is more versatile and a different defination(i.e. different sets of instruction for same function) is been called.
Wherein in the default argument, only one defination is there. The default argument are optional.If they are not specified,the compiler specifies them by default.

Remember all the default argument should be placed from right. i.e. func(int x, int z=1, int y) is not allowed. int z=1 should be on the right.
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 13
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: what does func(int x, int y, int z=1) mean?

  #5  
Nov 7th, 2007
I think he understands that. In use, however, there is no semantic difference.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 5:06 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC