Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

5 - exemplo: Orientação a Objetos

import std.stdio;
import std.string;

abstract class Pessoa {
   string nome; 
   
   string getNome() { 
      return nome;
   }

   abstract void print();
}

class Empregado : Pessoa {
   int empID;
   
   override void print() { 
      writeln("Detalhes do empregado:"); 
      writeln("ID: ", this.empID); 
      writeln("Nome: ", this.nome); 
   } 
}

void main() {
   Empregado emp = new Empregado(); 
   
   emp.empID = 101; 
   emp.nome = "Empregado101"; 
   emp.print();
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.