以下接连几篇文章来自于:http://www.acetheinterview.com,本人只是做了搜集整理工作。希望对大家有用。
c/c++ questions & answers (1’ ~ 21’)
1、what is polymorphism?
'polymorphism' is an object oriented term. polymorphism may be defined as the ability of related objects to respond to the same message with different, but appropriate actions. in other words, polymorphism means taking more than one form.
polymorphism leads to two important aspects in object oriented terminology - function overloading and function overriding.
overloading is the practice of supplying more than one definition for a given function name in the same scope. the compiler is left to pick the appropriate version of the function or operator based on the arguments with which it is called.
overriding refers to the modifications made in the sub class to the inherited methods from the base class to change their behaviour.
2、what is operator overloading?
when an operator is overloaded, it takes on an additional meaning relative to a certain class. but it can still retain all of its old meanings.
examples:
1) the operators >> and << may be used for i/o operations because in the <iostream> header, they are overloaded.
2) in a stack class it is possible to overload the + operattor so that it appends the contents of one stack to the contents of another. but the + operator still retains its original meaning relative to other types of data.
also polymorphism can be achieved in c++ through operator overloading
3、declare a void pointer.
i think the answer is simply