Reference types in the end is how is it?

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/bua200720411091/article/details/39718525
I believe the use of c ++ reference to the type of friends will not be unfamiliar, but, if we feel the pointer appears to be more important? References can do, pointers are not the same can be done it? And more powerful, and more flexible use ah. So references in the end is how you do it the father of c ++:?  ?? Dr. Jani Strauss special Loup then why would it not create a reference type it is only natural son pointer

        first, let's compare reference types and the difference between pointer types:
        1. the reference type can not be null, but the pointer
        2. achieve references must be based on variables that are currently available, they are only aliases existing variables they can not only survive independently of a reference type like a biological virus. , left the host, they will not survive alone while the pointer type is different, which is itself a separate data type, like int type as you can freely create and use them.  
        3. the reference type variable and tied forever set together, forbid replace its host. and how much freedom pointer, Oh, I think you know. 
        4. prohibit mutual reference type Assignment, and how pointer whatever you do. Only think, no can not make.   
        5. The reference address type itself is not available, you can not view references address type itself, you can see forever be a reference to the type of the address of that variable is referenced, but the pointer can address pointer itself can easily be displayed.
 
        Secondly, we look at java.
        I do not know of java reference type is how to see, and if looks are c ++ Like it? surface it seems, it is so ah. but in reality?
        Learn java all know, its a lot more than a simple memory model c ++. Java heap of objects can only be placed inside. And you want to access an object, you can only use the pointer. You might ask, where's the pointer java? I I want to have some understanding of java people understand that fact is not a reference to the type of java. but James Gosling and his little friends to java pointers changed the name, it becomes a reference. different names nothing more.  
         java pointers to access this feature only through the object, but also to promote their access objects on the syntax can omit the "*" no, that is a reference type in java. 
        so, reference java and c ++ reference type is not the type of the same, essentially speaking, c ++ there are references and pointers, but java only pointer. the most obvious example is in c ++, a reference to prohibit the assignment between types, but you will find in java you can do it. the fundamental the reason is in here.
        the Java for safety reasons, to cancel the function pointer arithmetic, but of course can be as c ++ increment decrement, freedom of movement, etc. arithmetic on the pointer. c ++ high cost of freedom is not enough Whole, because the movement of the pointer once out of control, field guide will appear, so if you use c ++, you have to force yourself to be a master, and not just stay in the language itself. C ++ programmer requires higher levels of it is a sharp matchless sword, to see if you are not able to manage the a. a matter of opinion.
       here also talking about that, do not always take the comparison between languages, without any need to. in fact, the development of general software features, c ++ can do, can do java, and java can not do that, but also because those functions in c ++ c language, rather than simply because c ++ just hope that we can find out.
        

Guess you like

Origin blog.csdn.net/bua200720411091/article/details/39718525