C++-常见英文面试笔试题
C/C++ Programming interview questions and answers
By Satish Shetty, July 14th, 2004What is encapsulation??
Containing and hiding information about an object, such as internal data structures and code. Encapsulation isolates(使隔离) the internal complexity of an object's operation from the rest of the application. For example, a client component asking for net revenue(收益) from a business object need not know the data's origin.
Inheritance allows one class to reuse the state
What is inheritance?
and behavior of another class. The derived class inherits
the
properties
and
method
implementations of the base class and extends it by overriding methods and adding additional properties and methods.
Polymorphism allows a client to treat different
What is Polymorphism??
objects in the same way even if they were created from different classes and exhibit(展现) different behaviors.
You can use implementation(实现) inheritance to achieve polymorphism in languages such as C++ and Java.
Base class object's pointer can invoke(调用) methods in derived class objects.
You can also achieve polymorphism in C++ by function overloading and operator overloading.
Constructor creates an object and initializes it.
What is constructor or ctor?
It also creates vtable变量列表? for virtual functions. It is different from other methods in a class.
Destructor usually deletes any extra resources
What is destructor?
allocated by the object.
Constructor with no arguments or all the
What is default constructor?
arguments has default values.