Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise 6.53 #188

Open
ElevenZwei opened this issue Aug 9, 2020 · 0 comments
Open

Exercise 6.53 #188

ElevenZwei opened this issue Aug 9, 2020 · 0 comments

Comments

@ElevenZwei
Copy link

Exercise information

Exercise 6.53

Explain the effect of the second declaration in each one of the following sets of declarations. Indicate which, if any, are illegal.
(C)
int calc(char*, char*);
int calc(char* const, char* const);

Question or Bug

Answer is "illegal" in https://github.com/pezy/CppPrimer/blob/master/ch06/README.md#exercise-653 .
But I think the second one is a legal redeclaration. Compiler treats them as one function. It will not make any warning as long as they don't have their own definitions which will trigger a redefinition error.

Your enviroment information

Tested on an online compiler.
https://www.onlinegdb.com/online_c++_compiler

int calc(char*, char*);
int calc(char* const a, char* const b) {
    cout << a << b << endl;
}
int main() {
    char s1[] = "Hello", s2[] = "World";
    calc(s1, s2);
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant