D语言函数重载

import std.stdio; 
import std.string; 

class printData { 
   public: 
      void print(int i) { 
         writeln(Printing int: ,i); 
      }

      void print(double f) { 
         writeln(Printing float: ,f );
      }

      void print(string s) { 
         writeln(Printing string: ,s); 
      } 
}; 

void main() { 
   printData pd = new printData();  

   // Call print to print integer 
   pd.print(5);

   // Call print to print float 
   pd.print(500.263); 

   // Call print to print character 
   pd.print(Hello D); 
}

相关文章

// ------------------- 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...