C++ Arguments

Started by
4 comments, last by Avont29 18 years, 10 months ago
im really not understanding what an argument is, can someone please help me to understand.. thanks in advance
Advertisement
It's essentially a variable that you pass to a function.
i know, i know, but what do they mean "Pass to a function"?
void func(int arg1, float arg2, string arg3)
Consider the following function, which adds two numbers together.

int add(int number1, int number2){    return number1 + number 2;}


"number1" and "number2" are the arguments of the "add" function. When we call "add" we "pass" values to that function in it's arguments:

int one = 1;int two = 2;// here we pass the variables "one" and "two" as arguments to the add functionint sum = add(one,two);


Does that help?
ohh, ok, i get it now, thanks fury :)

This topic is closed to new replies.

Advertisement