指针的两种不同类型的星号位置? [英] Two different types of asterisk locations for a pointer?
本文介绍了指针的两种不同类型的星号位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说你有这个..
int fry = 50;
现在创建一个指针并引用该值,可以通过两种不同的方式放置星号:
Now wen making a pointer and referencing the value, the asterisk can be placed two different ways:
int* d1 = &fry;
还有……
int *d1 = &fry;
我想知道有什么区别以及最好在什么情况下使用它们?谢谢!
I was wondering what the difference is and what situation it would be best to use each? Thanks!
推荐答案
没有区别.你甚至可以做 int*d1
和 int * d1
.
There is no difference. You can even do int*d1
and int * d1
.
在我看来,你应该更喜欢 int *d1
:这个选择在避免混淆方面有特别的作用:
In my opinion, you should prefer int *d1
: this choice has particular utility in avoiding confusion:
int* d1, d2;
int *d1, d2;
这些语句都声明了一个整数和一个指向整数的指针.第一个版本看起来很误导.
These statements both declare one integer and one pointer-to-integer. The first version looks quite misleading.
这篇关于指针的两种不同类型的星号位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文