What is the use of pure virtual class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the use of pure virtual class?

9th May 2017, 2:41 PM
Bilal Abbas
Bilal Abbas - avatar
1 Answer
+ 2
It allows you to define some basic properties of those classes that inherit from it, to ease interactions with your code. For instance: you have a program that will draw and update a chess board, but you're wanting to try multiple types of AI opponent. Define an abstract class which has the methods you need to let the plugged in AI play: ta-da, you create some child classes and experiment away. Or, even better, collaborate/crowd source the heuristics! On the surface, they can seem a bit odd, but abstract classes (or interfaces as java tends them) do come in handy.
10th May 2017, 3:21 AM
Jim
Jim - avatar