mercredi 15 septembre 2021

Static method in base class reflect the derived class name

Here is base class:

class Product
{
public:
    static void RegisterClass() {
        string b = __FUNCTION__;
    };
}

and here is the derived class.

class Milk: Product
{}

in the main function I call the static method this way:

main(){
    Milk.RegisterClass();
}

Then it writes value Product::RegisterClass into variable b. Is there a way to get value Milk::RegisterClass in the static method.

I don't want to instantiate the classes. And the main goal behind this scenario is to register Milk string somewhere.





Aucun commentaire:

Enregistrer un commentaire