1. Nayan Naware
  2. General
  3. Monday, 29 October 2018
Can we assign a base class handle which is not created to a extended class handle which is created?
Let say we have -

class A;

class B extends from A;

program main;
A my_a;
B my_b;

my_b = new();
initial begin
A = B; // If we do this what does it mean

//call tasks of A and B

According to me since we are doing my_b = new() it will create objects of B. Here we have only handle of A i.e. my_a so can we assign A = B if so what will it mean and how memory will be created?
Responses (1)
Accepted Answer Pending Moderation
A = B is a wrong statement. They are class definitions and not handles.
However you can do

my_a = my_b; //this is valid.
you cannot do
my_b = my_a ; //this is invalid.
you have to do

when you do my_a = my_b. you can call functions/tasks/variables that are declared in class A.
if you have any functions/tasks declared in class B you cannot do my_a.taskB();
  1. more than a month ago
  2. General
  3. # 1
  • Page :
  • 1

There are no replies made for this post yet.
However, you are not allowed to reply to this post.

You consent to our cookies if you continue to use our website. To know more about cookies, see our privacy policy. I accept cookies from this site.