Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
description:
There can only be one function with the same signature. Altering the cv qualification of parameters does not change the function signature. Therefore the two foo functions have the same signature and the program is ill-formed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
int foo(int x, int y)
{
return x+y;
}
int foo(const int x, const int y)
{
return x+y+1;
}
int main(int argc, char** argv)
{
const int x = 3;
const int y = 2;
std::cout << foo(x,y) << std::endl;
return 0;
}
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content