Languages [3i Infotech Placement]: Sample Questions 530 - 531 of 546

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 530


Write in Short

Short Answer▾

Write a program for recursive traverse?


void traverse (Node ⚹ head)


if (head == NULL)


cout << head ⇾ data << “” ;

traverse (head ⇾ next)

} ;

Question 531


Describe in Detail


What is name mangling?


  • Name mangling in c ++ compilers gives each function a unique name.
  • This is required in C ++ , all programs have a few functions with the same name. Name mangling allows linker to link to function names which are 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 manglingival________3BarConsider 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; …} ;
  • Thus, unambiguous access of either ival members is achieved through name mangling.
  • Member functions, because of overloading, require extensive mangling for unique names based on argument.

Developed by: