Function overloading, is this the correct definition?

Is the following definition for overloading functions in C++ correct?

"Overloading a function simply means taking a function that is named the exact same thing but has different types of arguments".
Is this correct? (I wrote that definition myself based off my current understanding of function overloading).
That sounds about right to me.
Or a different number of arguments but, yes, that pretty much sums it up. Note that the return type is not considered.
OK, now that I have the definition right..what is this called in PHP:
1
2
3
function whatever($hi, $hi2='hello') {

}

I have always thought (until today the $hi2='hello' was function overloading..so if not then what is that called.
That is called a default argument.
Last edited on
hi

i hope someone can help me understand this question:

Write a program that will calculate the circumference of a figure. The program must use two overloaded
functions, each named calcCircumference. The first function must calculate the circumference of a
circle, and will have one parameter of type double that represents the radius of the circle. The second function
will have two parameters of type double representing the length and width of a rectangle. Both functions must
calculate the circumference and return the value as type double.
The main function should request the user to specify whether the circumference of a rectangle or a circle must be
calculated, and depending on the answer, the user must either be prompted to enter the radius of the circle, or the
length and the width of the rectangle. The main function should then call the correct overloaded function and
display the circumference. Define a double constant variable PI with the value of 3.14285 to use for the
calculation of the circumference of the circle.


so far what i understood is:


#include <iostream>
using namespace std:

const double PI = 3.14285;
double calcCircumference( double radius);
double calcCircumference (double length, double width);

int main ()

{

double radius, calcCircumference;

//the rest i'm not sure
Topic archived. No new replies allowed.