- Function declarations that differ only by return type. For example,
you cannot declare the following declarations:
int f();
float f();
- Member function declarations that have the same name and the same
parameter types, but one of these declarations is a static member function
declaration. For example, you cannot declare the following two member
function declarations of f():
struct A {
static int f();
int f();
};
- Member function template declarations that have the same name, the same
parameter types, and the same template parameter lists, but one of these
declarations is a static template member function declaration.
- Function declarations that have equivalent parameter declarations.
These declarations are not allowed because they would be declaring the same
function.
- Function declarations with parameters that differ only by the use of
typedef names that represent the same type. Note that a
typedef is a synonym for another type, not a separate type.
For example, the following two declarations of f() are declarations
of the same function:
typedef int I;
void f(float, int);
void f(float, I);
- Function declarations with parameters that differ only because one is a
pointer and the other is an array. For example, the following are
declarations of the same function:
f(char*);
f(char[10]);
The first array dimension is insignificant when differentiating
parameters; all other array dimensions are significant. For
example, the following are declarations of the same function:
g(char(*)[20]);
g(char[5][20]);
The following two declarations are not equivalent:
g(char(*)[20]);
g(char(*)[40]);
- Function declarations with parameters that differ only because one is a
function type and the other is a pointer to a function of the same
type. For example, the following are declarations of the same
function:
void f(int(float));
void f(int (*)(float));
-
Function declarations with parameters that differ only because of
cv-qualifiers const, volatile, and restrict.
This restriction only applies if any of these qualifiers appears at the
outermost level of a parameter type specification. For example, the
following are declarations of the same function:
int f(int);
int f(const int);
int f(volatile int);
Note that you can differentiate parameters with const,
volatile and restrict qualifiers if you apply them
within a parameter type specification. For example, the
following declarations are not equivalent because const and volatile qualify int,
rather than *, and thus are not at the outermost level of the
parameter type specification.
void g(int*);
void g(const int*);
void g(volatile int*);
The following declarations are also not equivalent:
void g(float&);
void g(const float&);
void g(volatile float&);
- Function declarations with parameters that differ only because their
default arguments differ. For example, the following are declarations
of the same function:
void f(int);
void f(int i = 10);
- Multiple functions with extern "C" language-linkage and the
same name, regardless of whether their parameter lists are different.