在Java中,我們可以做到這一點:autoreferencing這個類在另一個用於C++
public class A{
public static void main(String...str){
B b = new B();
b.doSomething(this); //How I do this in c++ ? the this self reference
}
}
public class B{
public void doSomething(A a){
//Importat stuff happen here
}
}
我怎麼可以這樣做,但在C++中,我的意思是的自我參考使用B中的方法?
您確定要捕捉您的問題?'this'是C語言中的一個關鍵字,它仍然是這樣的。 – Potatoswatter 2010-04-06 05:11:53
你的代碼不會編譯。你不能在靜態上下文中使用'this'。 – 2010-04-06 05:21:00
是正確的我不能在靜態上下文中使用它,只是假設它不是靜態的 – atomsfat 2010-04-06 14:40:39