Multiple class inheritance

I have 3 classes all derived one after other , in third class I want to call the virtual function of first class , where the virtual function with same name is declared in all 3 classes how can I do that any views.

In reply to Ayush_1:

I have 3 classes all derived one after other , in third class I want to call the virtual function of first class , where the virtual function with same name is declared in all 3 classes how can I do that any views.


class A;
  
  virtual function void display();
    $display("Inside A");
  endfunction
  
endclass

class B extends A;
  
  virtual function void display();
    super.display();
    $display("Inside B");
  endfunction
  
endclass

class C extends B;
  
  virtual function void display();
    super.display();
    $display("Inside C");
  endfunction
  
endclass

 
  C c_h;
      
    c_h=new();
    c_h.display();
    
  end
  
endmodule

Regards,
Shanthi V A
www.maven-silicon.com

In reply to shanthi:

Hi Shanthi If there is no super.display in class B, then i need to access is it possible to access directly the class A function. Because in your example all 3 displays will come , i need to just have display of class A only not B.

In reply to Ayush_1:


class A;
 
  virtual function void display();
    $display("Inside A");
  endfunction

endclass
 
class B extends A;
 
  virtual function void display();
    super.display();
    $display("Inside B");
  endfunction

  function void display1();
    super.display();
  endfunction

endclass
 
class C extends B;
 
  virtual function void display();
    display1();
   endfunction
 
endclass
 
 
  C c_h;
 
    c_h=new();
    c_h.display();
 

In reply to shanthi:

class A;
 
  virtual function void display();
    $display("Inside A");
  endfunction
 
endclass
 
class B extends A;
 
  virtual function void display();
    super.display();
    $display("Inside B");
  endfunction
endclass
 
class C extends B;
 
  virtual function void display();
    A::display();
   endfunction
 
endclass

Thanks Shanthi and Dave. Both work pretty well!!