Answer Posted / atul shankhwar
Name mangling is the process through which your c++ compilers give each function in your program a unique name. In C++, all programs have at-least a few functions with the same name. Name mangling is a concession to the fact that linker always insists on all function names being unique.
Example:
In general, member names are made unique by concatenating the name of the member with that of the class e.g. given the declaration:
class Bar
{
public:
int ival;
...
};
ival becomes something like:
// a possible member name mangling
ival__3Bar
Consider this derivation:
class Foo : public Bar
{
public:
int ival;
...
}
The internal representation of a Foo object is the concatenation of its base and derived class members.
// Pseudo C++ code
// Internal representation of Foo
class Foo
{
public:
int ival__3Bar;
int ival__3Foo;
...
};
Unambiguous access of either ival members is achieved through name mangling. Member functions, because they can be overloaded, require an extensive mangling to provide each with a unique name. Here the compiler generates the same name for the two overloaded instances(Their argument lists make their instances unique).
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain virtual class?
What is the role of static keyword for a class member variable?
Perform addition, multiplication, subtraction of 2-D array using Operator Overloading.
What is an adaptor class or wrapper class in c++?
Are there interfaces in c++?
Differences between private, protected and public and give examples.
What is the full form of stl in c++?
What is difference between c++ 11 and c++ 14?
What is the maximum combined length of command line arguments including the space between adjacent arguments?
Write about a nested class and mention its use?
what is a reference variable in C++?
Where and why do I have to put the "template" and "typename" keywords?
Is sorted c++?
Do you know about C++ 11 standard?
Why namespace is used in c++?