Confusions about comparator_ooo_imps

Dear Sir/Madam,

I am looking at the example code attached at the end of this page.

In the analysis_imp version of the comparator (comparator_ooo_imps.svh), it has the following code

class comparator_ooo_imps #(type T = int, type IDX = int)
......
protected function void proc_data(T txn_data, input bit is_before);
    T txn_existing;
    IDX idx;
    string rs;
    q_of_T tmpq;
    bit need_to_compare;
    idx = txn_data.index_id();
.......

Since type T is unknown during compilation time and the default value for T is “int”. I wonder why we can directly access the member methods/variable inside txn_data without getting a compilation error? Given that during compilation time, we don’t know if txn_data really has member method index_id() inside it.

Thanks in advance for your help!

Hao

In reply to peterjin:

T and IDX are not a unknown types. Both are of type int. Where is the problem?

In reply to chr_sue:

Hi chr_sue,

Thanks for your reply.

My questions is on this line,
idx = txn_data.index_id();
Since txn_data has the default type of int, why an int type variable has a member method “index_id()”?

Thanks

Hao

In reply to peterjin:

Resolution of class based functions is performed at elaboration, not compilation. If you instantiate this class and don’t override the default types, you will get an error. The type you provide as an override is expected to provide the appropriate functions.

In reply to cgales:

Thanks for the explanation! That solves my confusion.