C ++引用Vs C#引用 [英] C++ references Vs C# references

查看:170
本文介绍了C ++引用Vs C#引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++参考 C#参考 之间的同义词/区别是什么?

What are the similarties/differences between a C++ reference and a C# reference ?

编辑

我不知道,这样一个简单的行会造成歧义,因为我已经阅读。每当使用术语引用时,其在上下文中为对象引用,否则其被明确引用为托管引用

I'm talking about Object references,as I'm a newbie I was unaware that such a simple line would cause ambiguity,as I have read. Whenever the term "reference" is used,its in context to Object reference,otherwise its explicitly quoted as "managed references".

我认为所有回答这个问题的人都得到了我想说的话,我发表了一个评论,清楚地说明了我想问的问题。我没有看到任何理由的downvote,来的人。

I think all the people who have answered this question have got what I was trying to say and I made a comment that states clearly what I wanted to ask. I don't see any reason for a downvote,come on guys.

这个问题不应该被关闭。像我这样的新手可以从洞察学到很多的有经验的人提供。

This question does not deserve to be closed.As newbies like me can learn from the insight a lot of experienced people have provided.

推荐答案

C#引用比C ++引用更接近C ++指针。

C# references are closer to C++ pointers than to C++ references.

C#引用可以为null,并且具有与指针类似的赋值语义。区别是它们是黑盒子(你不能将它们转换为整数类型),你不能对它们进行算术。它们也只能指向引用类型。

C# references can be null and have assignment semantics similar to pointers. The difference is that they are black boxes(you can't convert them to integral types) and you can't do arithmetic on them. They also can only point to reference types.

C ++引用是完全不同的(除了编译为指针)。它们更接近用于 ref 参数的.net管理引用。

C++ references are quite different(apart from being compiled to pointers too). They are closer to .net managed references which are used for ref parameters. But even then the assignment semantics differ.


引用的初始化是完全不同的赋值给它。尽管出现 -
ances,没有操作符对引用操作。

Initialization of a reference is something quite different from assignment to it. Despite appear- ances, no operator operates on a reference.

这篇关于C ++引用Vs C#引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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