变量的别名 [英] alias for a variable

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

问题描述

嗨朋友们,


我们可以在C中使用变量的别名。


就像我定义一个int ---

int示例;


现在我想要另一个变量,即示例的别名。我

意味着示例和另一个变量让我们说example2拥有相同内存的

,但我们正在用两个变量进行渲染。

我需要两者都是全局变量。


我不是在谈论通过引用进行调用,而是可以使用#define。我是吗?


问候,

Paresh

Hi Friends,

Can we have a alias of a variable in C.

Like I define an int---
int example;

Now I want another variable that is the alias for the "example". I
meant both example and another variable let say "example2" have the
same memory but we are refrencing with it by two variables.
I need both to be global variables.

I am not talking about call by reference and I can use #define. Am I?

Regards,
Paresh

推荐答案

paresh说:
paresh said:

嗨朋友们,


我们可以在C中使用变量的别名。


就像我定义一个int ---

int例子;


现在我想要另一个变量,即别名"示例" ;.我

意味着示例和另一个变量让我们说example2拥有相同内存的

,但我们正在通过两个变量重新启动它。
Hi Friends,

Can we have a alias of a variable in C.

Like I define an int---
int example;

Now I want another variable that is the alias for the "example". I
meant both example and another variable let say "example2" have the
same memory but we are refrencing with it by two variables.



是的,您可以使用#define,或者您只需将两个指针指向

同一个对象。

Yes, you could use #define, or you could simply point two pointers at
the same object.


我需要两者都是全局变量。
I need both to be global variables.



为什么你需要这样做?

Why on earth would you need to do that?


我不是在谈论参考电话
I am not talking about call by reference



C中没有这样的东西。

No such thing in C.


我可以使用#define。
and I can use #define.



是的,你可以。

Yes, you can.


我?
Am I?



你是什么?


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名, - www。

Am you what?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


2月15日凌晨1点59分,paresh ; < pareshvarsh ... @ gmail.comwrote:
On Feb 15, 1:59 am, "paresh" <pareshvarsh...@gmail.comwrote:

嗨朋友们,


我们能否拥有变量的别名在C.


就像我定义一个int ---

int例子;


现在我想要另一个变量,它是example的别名。我

意味着示例和另一个变量让我们说example2拥有相同内存的

,但我们正在用两个变量进行渲染。

我需要两者都是全局变量。


我不是在谈论通过引用进行调用,而是可以使用#define。我呢?
Hi Friends,

Can we have a alias of a variable in C.

Like I define an int---
int example;

Now I want another variable that is the alias for the "example". I
meant both example and another variable let say "example2" have the
same memory but we are refrencing with it by two variables.
I need both to be global variables.

I am not talking about call by reference and I can use #define. Am I?



您是否正在寻找工会?


Are you perhaps looking for a union?


2月15日,2:01下午,robertwess ... @ yahoo.com

< robertwess ... @ yahoo.comwrote:
On Feb 15, 2:01 pm, "robertwess...@yahoo.com"
<robertwess...@yahoo.comwrote:

2月15,15:59 am,paresh < pareshvarsh ... @ gmail.comwrote:
On Feb 15, 1:59 am, "paresh" <pareshvarsh...@gmail.comwrote:

嗨朋友们,
Hi Friends,


我们可以在C中有一个变量的别名。
Can we have a alias of a variable in C.


就像我定义一个int ---

int example;
Like I define an int---
int example;


现在我想要另一个变量,即示例的别名。我

意味着示例和另一个变量让我们说example2有两个相同的内存,但是我们用两个变量对它进行了改进。

我需要两个都是全局变量。
Now I want another variable that is the alias for the "example". I
meant both example and another variable let say "example2" have the
same memory but we are refrencing with it by two variables.
I need both to be global variables.


我不是在谈论通过引用调用,我可以使用#define。我呢?
I am not talking about call by reference and I can use #define. Am I?



您是否正在寻找工会?


Are you perhaps looking for a union?



不,我不是在寻找工会。是的,最简单的方法是

#define。

还有其他办法吗?


No I am not looking for union. Yes the easiast way to do this is
#define.
Is there any other way?


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

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