您的位置:首页 > 编程语言 > C语言/C++

Pure Virtual Functions and Abstract Classes in C++

2017-04-20 11:29 549 查看
reference http://quiz.geeksforgeeks.org/pure-virtual-functions-and-abstract-classes/

1) A class is abstract if it has at least one pure virtual function.

2) We can have pointers and references of abstract class type.

 

3) If we do not override the pure virtual function in derived class, then derived class also becomes abstract class.

4) An abstract class can have constructors.

For example, the following program compiles and runs fine.

{


 

Interface vs Abstract Classes:

An interface does not have implementation of any of its methods, it can be considered as a collection of method declarations. In C++, an interface can be simulated by making all methods as pure virtual.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: