Am I good enough for c++?

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 12
Reputation: cscotty is an unknown quantity at this point 
Solved Threads: 0
cscotty cscotty is offline Offline
Newbie Poster

Switch Vs. Function

 
0
  #1
Jun 6th, 2005
Are they the same? If so, which one is preferred by the more advance programmer and why?

Thanks,
Scott
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Am I good enough for c++?

 
0
  #2
Jun 6th, 2005
>> Are they the same?
Kinda sorta, but not really. A switch is a control flow structure that directs execution through a certain block of code depending on an integral value. In other words, it's like door #1, door #2, and door #3 in the old gameshows. Those three doors together would be the body of a switch, 1, 2, and 3 would be the cases, and the condition is the very confused contestant trying to pick which one to open.

A function is a named block of code that can optionally accept data to work with and optionally return data when it's done. Think of a function like a drive through carwash. The carwash is the function, a dirty car going in is an argument, the body of the function cleans the car, and a clean car coming out is the return value.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 12
Reputation: cscotty is an unknown quantity at this point 
Solved Threads: 0
cscotty cscotty is offline Offline
Newbie Poster

Re: Am I good enough for c++?

 
0
  #3
Jun 6th, 2005
Thanks Dogtree.. Let me know. If you were to do a multiple choice question, which would you use. Switch or Function?

Scott
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Am I good enough for c++?

 
0
  #4
Jun 6th, 2005
Anytime you need to split off into one or more separate paths, you're looking at a switch or if chain.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 1542 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC