In reply to dave_59:
Hi Dave,
I have been always receiving useful information from you always. On the same topic which Parth asked for, I have tried this in c++ and it’s allowing child class non virtual method from parent class handle using dynamic_cast. It requires only 1 method declaration as virtual in base class to make it polymorphic class.
Here is the code:
include iostream
using namespace std;
class Base {
public:
void show()
{
cout << " In Base \n";
}
};
class Derived : public Base {
public:
void display()
{
cout << “In Derived \n”;
}
};
int main(void)
{
Base* bp = new Derived;
// RUN-TIME POLYMORPHISM
((Derived *)bp)->display();
return 0;
}
I’m looking similar with system verilog class. I tried using $cast but it’s not allowing to access child class non virtual method.
Is it a limitation of SV over C++ by means of dynamic_cast?
Anyone’s view/comments are welcomed.