Reputation: 459
suppose I have a class with one of the method member name is close, and inside the class, I'm using C function to open and close file
thus, I will have two completely different function with the same name, but one is C and another is C++.
Thus, when I call close, seems compiler is confused
s = socket(PF_INET, SOCK_DGRAM, 0);
close(s)
how to solve this issue? Thanks
Upvotes: 1
Views: 517
Reputation: 662
the compiler usually change the name of functions you define to some unique function name. so if you use function overriding the compiler has its unique name for every function. This is done with the help of name mangling in C++. You should read the concept of name mangling that can help you solve the issue.
Upvotes: 0
Reputation: 83205
Your member function:
close(s)
Function in global namespace:
::close(s)
Upvotes: 6