关于演员的问题 [英] question about cast

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

问题描述

有谁知道为什么


void main(){

double x;

double * y;

(int)y = x;

}


编译好,为什么


void main(){

double x;

double * y;

(double)y = x;

}


编译得不好?!?

为什么在seconde案例中不允许将指针强制转换为double?

谢谢

Yacine

Does anyone know why

void main(){
double x;
double *y;
(int) y = x;
}

compiles well, and why

void main(){
double x;
double *y;
(double) y = x;
}

does not compile well ?!?
Why is it not allowed to cast a pointer to a double in the seconde case ?
Thanks
Yacine

推荐答案

Yacine< ya ** @ netcourrier.com>这样说:
Yacine <ya**@netcourrier.com> spoke thus:
void main(){
void main(){




在那里举行。听起来像你可以使用

http://www.eskimo.com/~scs/C-faq/top.html


-

Christopher Benson-Manica |我*应该*知道我在说什么 - 如果我

ataru(at)cyberspace.org |不,我需要知道。火焰欢迎。



Hold it right there. Sounds like you could use

http://www.eskimo.com/~scs/C-faq/top.html

--
Christopher Benson-Manica | I *should* know what I''m talking about - if I
ataru(at)cyberspace.org | don''t, I need to know. Flames welcome.


Yacine< ya ** @ netcourrier.com>写道:
Yacine <ya**@netcourrier.com> wrote:
有谁知道为什么

void main(){
double x;
double * y;
(int)y = x;
}
编译好,


因为你的实现被破坏了,或者你称之为错误

方式。 main()返回int。演员和随后的作业大约和布什少年的真实性一样可疑,顺便说一句。

void main(){
double x;
double * y;
(double)y = x;
}
编译不好?!?
Does anyone know why

void main(){
double x;
double *y;
(int) y = x;
}

compiles well,
Because your implementation is broken, or you''re calling it the wrong
way. main() returns int. The cast and subsequent assignment are about as
dubious as Bush Junior''s veracity, btw.
void main(){
double x;
double *y;
(double) y = x;
}

does not compile well ?!?




因为将指针强制转换为int是可疑的,但是可能,同时施放

a指向double的指针毫无意义。


Richard



Because casting a pointer to int is dubious, but possible, while casting
a pointer to double makes no sense at all.

Richard


Richard Bos写道:
Richard Bos wrote:
Yacine< ya ** @ netcourrier.com>写道:

Yacine <ya**@netcourrier.com> wrote:

有谁知道为什么

void main(){
double x;
double * y;
(int)y = x;
}
编译好,
Does anyone know why

void main(){
double x;
double *y;
(int) y = x;
}

compiles well,



因为你的实现被破坏了,或者你是称之为错误的方式。 main()返回int。演员和随后的任务与布什少年的真实性一样可疑,顺便说一句。


Because your implementation is broken, or you''re calling it the wrong
way. main() returns int. The cast and subsequent assignment are about as
dubious as Bush Junior''s veracity, btw.

void main(){
double x ;
双* y;
(双)y = x;
}
编译不好?!?
void main(){
double x;
double *y;
(double) y = x;
}

does not compile well ?!?



因为将指针强制转换为int是可疑的,但是可能,同时施放指向double的指针根本就​​没有意义。

Richard


Because casting a pointer to int is dubious, but possible, while casting
a pointer to double makes no sense at all.

Richard



main的返回类型与我正在谈论的问题无关

。我的问题是:是否可以将指针转换为双精度?我认为将指针强制转换为int而不是施放

a指针加倍...


The return type of main has nothing to do with the problem I''m talking
about. My question is: is it possible to cast a pointer to a double ? I
think it does not make more sense to cast a pointer to int than casting
a pointer to double ...


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

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