D语言抽象类

import std.stdio;
import std.string;
import std.datetime;

abstract class Person {
   int birthYear, birthDay, birthMonth; 
   string name; 

   int getAge() {
      SysTime sysTime = Clock.currTime(); 
      return sysTime.year - birthYear;
   }
}

class Employee : Person {
   int empID;
}

void main() {
   Employee emp = new Employee(); 
   emp.empID = 101; 
   emp.birthYear = 1980; 
   emp.birthDay = 10; 
   emp.birthMonth = 10; 
   emp.name = Emp1; 

   writeln(emp.name); 
   writeln(emp.getAge); 
}

相关文章

// ------------------- import std.stdio; void main(str...
import std.stdio; int main () { /* local variable defi...
import std.stdio; int main(string[] args) { int a = 20...
import std.stdio; int main(string[] args) { int a = 4;...
import std.stdio; int main(string[] args) { int a = 21;...
import std.stdio; int main(string[] args) { uint a = 60...