I have the superclass A, and its subclass B and C.
I have the class D, and its member:
A* aArray[20]
but in aArray, there will be just B and C objects.
I want to implement a function that will count the number of Bs in this array, but I could not think of an effective solution.
My solution is to write getType function in each class, and check if it is ‘a’, ‘b’, ‘c’ in the function of D.
For example, for the subclass B:
virtual char getType() const{
return 'b'
};
Is it the correct way to implement this?