| | |
User defined functions
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hello everyone,
Could you please explain to me how to write the user defined functions with multiple arguments? (specifically with 2 or 3 input arguments). And also, how to make one function to manipulate different data each time it is called? (for example area of bigger circle minus area of the smaller circle with one findArea function) To be specific, can you show me Prototype, function definition, and function call?
My C++ book doesn't explain it clearly.
Thank you very much
Could you please explain to me how to write the user defined functions with multiple arguments? (specifically with 2 or 3 input arguments). And also, how to make one function to manipulate different data each time it is called? (for example area of bigger circle minus area of the smaller circle with one findArea function) To be specific, can you show me Prototype, function definition, and function call?
My C++ book doesn't explain it clearly.
Thank you very much
>Could you please explain to me how to write the
>user defined functions with multiple arguments?
There are three patterns for function parameters. First is a function with no parameters:
No parameters is described in code using parentheses where there's nothing between them. Next is a single parameter, which is described in code using a variable declaration between the parentheses:
The third pattern applies to all other numbers or parameters, just keep adding variable declarations and separate them with a comma:
>how to make one function to manipulate different data each time it is called?
Pass in different values with each call. Those values will be copied into the variables you declare in the parameter list:
>user defined functions with multiple arguments?
There are three patterns for function parameters. First is a function with no parameters:
C++ Syntax (Toggle Plain Text)
void foo();
C++ Syntax (Toggle Plain Text)
void foo(int bar);
C++ Syntax (Toggle Plain Text)
void foo(int bar, double baz, string meep);
Pass in different values with each call. Those values will be copied into the variables you declare in the parameter list:
C++ Syntax (Toggle Plain Text)
#include <iostream> int add_all ( int a, int b, int c ) { return a + b + c; } int main() { std::cout<< add_all ( 0, 1, 2 ) <<'\n'; std::cout<< add_all ( 3, 4, 5 ) <<'\n'; }
I'm here to prove you wrong.
There is lots of information on the web that explains those things for you. Just search google
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- User defined functions (C++)
- User-defined functions (C++)
- User-Defined Function - part 2 (C++)
- help:stl vector of user defined objects (C)
- accessing common user-defined functions (ASP.NET)
- DECLARATION SYNTAX ERROR (for bc 31 user) (C++)
- User defined functions (C++)
Other Threads in the C++ Forum
- Previous Thread: Address book
- Next Thread: Recursion programming help
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project proxy python random read recursion recursive return sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






