deference运算符和指针之间有什么区别 [英] what is the difference between deference operator and pointer

查看:200
本文介绍了deference运算符和指针之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int x,a;

a = 10

x =& a;

cout<< * x; //使用取消引用运算符

这将打印值10

另一种情况是

int * x; // x是指针变量

int a = 10;

x =& a;

cout<< * x; //打印价值10

这两种情况有什么区别?

int x,a;
a=10
x=&a;
cout<<*x; //using dereference operator
this will print value 10

the other case is
int *x; //x is a pointer variable
int a=10;
x=&a;
cout<<*x; //printing value 10

what is the difference between these two cases?

推荐答案

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

int x,a;

a = 10

x =& a;

cout<< * x; //使用取消引用运算符

这将打印值10

另一种情况是

int * x; // x是指针变量

int a = 10;

x =& a;

cout<< * x; //打印价值10

这两种情况有什么区别?
int x,a;
a=10
x=&a;
cout<<*x; //using dereference operator
this will print value 10

the other case is
int *x; //x is a pointer variable
int a=10;
x=&a;
cout<<*x; //printing value 10

what is the difference between these two cases?



1.不要发布多个倍。我们第一次听到你了。


2.试试C ++新闻组。 C语言与你发布的语言不同

这里。

1. Don''t post multiple times. We heard you the first time.

2. Try a C++ newsgroup. C is a different language than what you posted
here.


sa ************* @ gmail.com 写道:
sa*************@gmail.com wrote:

int x,a;

a = 10

x =& a;
int x,a;
a=10
x=&a;



这是一个错误,你不能将指针值存储在int中。

你的编译器没抱怨吗? br />

this is an error you can''t store a pointer value in an int.
Didn''t your compiler complain?


cout<< * x; //使用取消引用运算符
cout<<*x; //using dereference operator



这不是C

this isn''t C


这将打印值10
this will print value 10



没有它不会

no it won''t


另一种情况是

int * X; // x是指针变量

int a = 10;

x =& a;

cout<< * x; //打印价值10

这两种情况有什么区别?
the other case is
int *x; //x is a pointer variable
int a=10;
x=&a;
cout<<*x; //printing value 10

what is the difference between these two cases?



一个给出诊断,另一个没有


-

Nick Keighley


Dan Pop:你最后一次实施真实生活

应用程序是一个严格遵守的程序吗?

Richard Heathfield:约20分钟前。这是一项全新的,优质的b $ b优化的猪发射程序,它使我们在之前的猪类航空计划上增加了70%的范围。

one gives a diagnostic the other doesn''t

--
Nick Keighley

Dan Pop: "When was the last time you''ve implemented a real life
application as a strictly conforming program?"
Richard Heathfield: "About 20 minutes ago. It was a new, heavily
optimised pig-launching routine, which gets us a 70% range increase
on previous porcine aeronautic programs."


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

>

int x,a;

a = 10

x =& a;

cout<< * x; //使用取消引用运算符

这将打印值10

另一种情况是

int * x; // x是指针变量

int a = 10;

x =& a;

cout<< * x; //打印价值10

这两种情况有什么区别?
>
int x,a;
a=10
x=&a;
cout<<*x; //using dereference operator
this will print value 10

the other case is
int *x; //x is a pointer variable
int a=10;
x=&a;
cout<<*x; //printing value 10

what is the difference between these two cases?



不要多次发布同一篇文章。


两者都未定义。 cout是未宣布的。即使它是,但是将
移动10并且丢弃结果是没有意义的。

为int分配地址​​也是未定义的。可执行代码

不允许使用函数体。


也许您正在考虑除C以外的其他语言? C ++来了

介意,关于它的问题更好地针对comp.lang.c ++。


-

Chuck F(cinefalconer at maineline dot net)

可用于咨询/临时嵌入式和系统。

< http://cbfalconer.home.att.net>

-

通过 http:的免费Usenet帐户发布//www.teranews.com

Don''t post the same article more than once.

Both are undefined. cout is undeclared. Even if it was, left
shifting it by 10 and discarding the result is meaningless.
Assigning an address to an int is also undefined. Executable code
outside of a function body is not allowed.

Maybe you are thinking of some other language than C? C++ comes to
mind, and questions about it are better aimed at comp.lang.c++.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com


这篇关于deference运算符和指针之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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