| | |
Am I good enough for c++?
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
>> 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.
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.
![]() |
Similar Threads
- Good books on Shell Programming/Perl (Perl)
- Newsletter pop-under / Good or bad idea? (Website Reviews)
- Good Ol' Windoze 9x (Windows 95 / 98 / Me)
- Where can I buy a good computer? (Geeks' Lounge)
- Know of a good program? (IT Professionals' Lounge)
- Good Luck! (Geeks' Lounge)
- ThemeXP is back! (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: vc++ mfc-i can't make getline work with a string for file input
- Next Thread: Is there a 'parent' stl container class?
Views: 1542 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





