面试时最经常被问到的问题(Frenquently asked interview questions)之C/C++篇[1]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 mxclxp 的 blog

以下接连几篇文章来自于:http://www.acetheinterview.com,本人只是做了搜集整理工作。希望对大家有用。

c/c++ questions & answers (1’ ~ 21’)

 

1what 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.

 

2what 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

3declare a void pointer.

i think the answer is simply

本文关键:面试时最经常被问到的问题(Frenquently asked interview questions)之C/C++篇
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top