lundi 1 février 2021

Acessing subclass variable from base class object

Let's say i'm having the following classes in c++

class Animal{}
class Dog extends Animal {
    int barkingVolume;
}

However, i don't have the header file for Dog class. But i have the object of Dog of type Animal at runtime. The question is how I can access the variable barkingVolume?
Animal animalButDogObject;//someone has set the value at runtime
I need to access barkingVolume from animalButDogObject.

Actual scenario from COM/Directshow: I'm having IBaseFilter object which is of type IVendorFilter(custom filter from 3rd party vendor which extended IBaseFilter). While debugging using Visual studio i can see the type is IVendorFilter and it has variables which i need to change. However i cannot figure out how to do it. I cannot find anything like a reflection/evalutation in CPP

Aucun commentaire:

Enregistrer un commentaire