这是什么? [英] what's this?

查看:76
本文介绍了这是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< iostream>


struct zaman {

float p;

};


typedef int(* func)(zaman,int);


int main(){

func(-1); //嗯。这是什么?

std :: getchar();

返回0;

}


为什么func(-1)正在工作?

实际上,我在DON BOX的书中找到了这个(等效代码)


- ------------------

typedef HRESULT(* INTERFACE_FINDER)(void * pThis,DWORD dwData,REFIID

riid ,void ** ppv);


//伪函数表示条目只是一个偏移量

#define ENTRY_IS_OFFSET INTERFACE_FINDER(-1)

--------------


是不是INTERFACE_FINDER(-1)调用函数?它是如何抵消的?

解决方案

ba ****@gmail.com 写道:


请不要在Usenet上多发帖子。


- -

Ian Collins。


ba **** @ gmail.com 写道:


#include< iostream>


struct zaman {

浮动p;

};


typedef int(* func)(zaman,int);


int main(){

func(-1); //嗯。这是什么?

std :: getchar();

返回0;

}


为什么func(-1)工作?


实际上,我在DON BOX的书中找到了这个(等效代码)


--------------------

typedef HRESULT(* INTERFACE_FINDER)(void * pThis,DWORD dwData,REFIID

riid,void ** ppv);


//伪函数表示条目只是一个偏移量

#define ENTRY_IS_OFFSET INTERFACE_FINDER(-1 )

--------------


是不是INTERFACE_FINDER(-1)调用函数?它是如何抵消的?



func是一种类型,INTERFACE_FINDER是一种类型,因此它们无法运行

调用。相反,它们是强制转换,-1强制转换为函数指针。


john


6月25日,1:57 am,John Harrison< john_androni ... @ hotmail.comwrote:


bak ... @ gmail.com写道:


#include< iostream>


struct zaman {

float p;

};


typedef int(* func)(zaman,int);


int main(){

func(-1); //嗯。这是什么?

std :: getchar();

返回0;

}

< blockquote class =post_quotes>
为什么func(-1)工作?


实际上,我在DON BOX的书中发现了这个(等效代码)


--------------------

typedef HRESULT(* INTERFACE_FINDER)(void * pThis,DWORD dwData,REFIID

riid,void ** ppv);


//伪函数表示条目只是一个偏移量

#define ENTRY_IS_OFFSET INTERFACE_FINDER(-1)

--------------


Isn't INTERFACE_FINDER(-1)a打电话给一个功能?它是如何抵消的?



func是一种类型,INTERFACE_FINDER是一种类型,因此它们无法运行

来电。相反,他们是强制转换,-1强制转换为函数指针。


john



对不起,那个'这就是我删除它的原因。所以,如果它是一个演员,为什么不用这个工作用c ++


int *( - 1);


但是func(-1);有效吗?


#include<iostream>

struct zaman{
float p;
};

typedef int (*func)(zaman, int);

int main(){
func(-1); //Hmmm. what''s this?
std::getchar();
return 0;
}

why is func(-1) working?
Actually, I found this (equivalent code) in DON BOX''s book

--------------------
typedef HRESULT (*INTERFACE_FINDER) (void *pThis, DWORD dwData, REFIID
riid, void **ppv);

//pseudo-function to indicate entry is just an offset
#define ENTRY_IS_OFFSET INTERFACE_FINDER(-1)
--------------

Isn''t INTERFACE_FINDER(-1) a call to a function? How is it an offset?

解决方案

ba****@gmail.com wrote:

Please don''t multi-post on Usenet.

--
Ian Collins.


ba****@gmail.com wrote:

#include<iostream>

struct zaman{
float p;
};

typedef int (*func)(zaman, int);

int main(){
func(-1); //Hmmm. what''s this?
std::getchar();
return 0;
}

why is func(-1) working?
Actually, I found this (equivalent code) in DON BOX''s book

--------------------
typedef HRESULT (*INTERFACE_FINDER) (void *pThis, DWORD dwData, REFIID
riid, void **ppv);

//pseudo-function to indicate entry is just an offset
#define ENTRY_IS_OFFSET INTERFACE_FINDER(-1)
--------------

Isn''t INTERFACE_FINDER(-1) a call to a function? How is it an offset?

func is a type, INTERFACE_FINDER is a type, so they can''t be function
calls. Instead they''re casts, -1 cast to a function pointer.

john


On Jun 25, 1:57 am, John Harrison <john_androni...@hotmail.comwrote:

bak...@gmail.com wrote:

#include<iostream>

struct zaman{
float p;
};

typedef int (*func)(zaman, int);

int main(){
func(-1); //Hmmm. what''s this?
std::getchar();
return 0;
}

why is func(-1) working?

Actually, I found this (equivalent code) in DON BOX''s book

--------------------
typedef HRESULT (*INTERFACE_FINDER) (void *pThis, DWORD dwData, REFIID
riid, void **ppv);

//pseudo-function to indicate entry is just an offset
#define ENTRY_IS_OFFSET INTERFACE_FINDER(-1)
--------------

Isn''t INTERFACE_FINDER(-1) a call to a function? How is it an offset?


func is a type, INTERFACE_FINDER is a type, so they can''t be function
calls. Instead they''re casts, -1 cast to a function pointer.

john

I am sorry, that''s why I deleted it. So, if it is a cast why doesn''t
this work in c++

int* (-1);

but func(-1); works?


这篇关于这是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆