mirror of
https://github.com/preservim/tagbar.git
synced 2025-02-21 10:05:40 +08:00
61 lines
1.4 KiB
Plaintext
61 lines
1.4 KiB
Plaintext
class A {
|
|
public integer data;
|
|
local integer addr;
|
|
protected integer cmd;
|
|
static integer credits;
|
|
task new() {
|
|
data = 100;
|
|
addr = 200;
|
|
cmd = 1;
|
|
credits = 10;
|
|
}
|
|
task printA() {
|
|
printf ("value of data %0d in A\n", data);
|
|
printf ("value of addr %0d in A\n", addr);
|
|
printf ("value of cmd %0d in A\n", cmd);
|
|
}
|
|
}
|
|
|
|
class B extends A {
|
|
task printB() {
|
|
printf ("value of data %0d in B\n", data);
|
|
// Below line will give compile error
|
|
//printf ("value of addr %0d in B\n", addr);
|
|
printf ("value of cmd %0d in B\n", cmd);
|
|
}
|
|
}
|
|
|
|
class C {
|
|
A a;
|
|
B b;
|
|
task new() {
|
|
a = new();
|
|
b = new();
|
|
b.data = 2;
|
|
}
|
|
task printC() {
|
|
printf ("value of data %0d in C\n", a.data);
|
|
printf ("value of data %0d in C\n", b.data);
|
|
// Below line will give compile error
|
|
//printf ("value of addr %0d in C\n", a.addr);
|
|
//printf ("value of cmd %0d in C\n", a.cmd);
|
|
//printf ("value of addr %0d in C\n", b.addr);
|
|
//printf ("value of cmd %0d in C\n", b.cmd);
|
|
}
|
|
}
|
|
|
|
program properties {
|
|
C c = new();
|
|
c.a.printA();
|
|
c.b.printB();
|
|
c.printC();
|
|
printf("value of credits is %0d\n",c.a.credits);
|
|
printf("value of credits is %0d\n",c.b.credits);
|
|
c.a.credits ++;
|
|
printf("value of credits is %0d\n",c.a.credits);
|
|
printf("value of credits is %0d\n",c.b.credits);
|
|
c.b.credits ++;
|
|
printf("value of credits is %0d\n",c.a.credits);
|
|
printf("value of credits is %0d\n",c.b.credits);
|
|
}
|