Guest User

Untitled

a guest
Apr 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. module main;
  2.  
  3. import tango.io.Stdout;
  4.  
  5. template addressOf( alias fn ) {
  6. const addressOf = &fn;
  7. }
  8.  
  9. class A {
  10. void foo( int a ) {}
  11. void foo( float a ) {}
  12.  
  13. final void bar() {
  14. auto dg = &foo;
  15. if ( addressOf!( foo ) == dg.funcptr ) {
  16. Stdout( "not overridden" ).newline;
  17. } else {
  18. Stdout( "overridden" ).newline;
  19. }
  20. }
  21. }
  22.  
  23. class B : A {
  24. override void foo( int a ) {}
  25. }
  26.  
  27. void main() {
  28. A a = new A();
  29. a.bar;
  30.  
  31. A b = new B();
  32. b.bar;
  33. }
Add Comment
Please, Sign In to add comment