www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Calling an alias for a Class method in another scope


Kindly make me understand this. I have been trying to call an alias for a
class method from another scope. I keep getting an error saying that I need
"this" to call a method. Why will not "this" pointer be available when I am
passing the method symbol along with an object of the class? Is there
another way of doing what I am trying to achieve. I have pasted a sample
code below here.

- Puneet

void callfoo(alias F, T) (T t) {
  void foo() {
    F();   // Error: need 'this' to access member foo
    t.F(); // Error: undefined identifier 'F'

class Foo {
  void foo() {}

void main() {
  Foo f = new Foo();
May 31 2012