vc 中内嵌汇编 怎样调用类的成员函数?

class x
{
       
int a;
       pbulic:
            f(
int b)
           
{
                 a
=b;
           }

}


int fn(int n)
{
       
return n*n;
}


void main()
{
     
int a,b;
     __asm
    
{
           push 
2;
           call fn; 
//编译通过 求一个数的平方
           sub esp,4;
           mov a,eax;
    }

    x c;
    
    __asm
   
{
         push 
0;
         lea ecx,c;
         call x::f 
//这个地方就错误了 我该如何题名这个函数呢?
    }

}

最佳答案
class x
{
       
int a;
       pbulic:
           
static void f(int b) //加上static 是静态函数才可以class::fun()调用
           {
                  a
=b;
            }

}
 ;//这里要有分号

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章