From a discussion that occurred in my recent question ( Why is a C ++ link considered safer than a pointer? ), This raises another question for me: what exactly was the rationale for implementing links in C ++?
Section 3.7 Stroustrup The design and evolution of C ++ describes the introduction of language references. If you are interested in justifying any C ++ function, I highly recommend this book.
. , . , "", , , . 68.C , , . , . , , . :a = b - c; ( ) ,a = &b - &c; . , &b - &c C, ., . , ++ , . Algol68 r1 = r2 r1 , r1 ( r1) r2. ++.
. , . , "", , , . 68.
C , , . , . , , . :
a = b - c;
( ) ,
a = &b - &c;
. , &b - &c C, .
&b - &c
, . , ++ , . Algol68 r1 = r2 r1 , r1 ( r1) r2. ++.
r1 = r2
r1
r2
(, " ?" )
std::auto_ptr::operator*() ? std::vector::operator[]?
std::auto_ptr::operator*()
std::vector::operator[]
. , , , - ++ *. , . , - - , ( ) ..
, , .
, , ++, (), .
, , - , , , . , , , . , .
"" - , ++ . , , . , -, . , - , , , .
Allow operator overload. They wanted operators to be overloaded for both objects and pointers, so they needed a way to refer to the object with something other than a pointer. Therefore, a link has been introduced. It is in the "Project and Evolution of C ++".
Source: https://habr.com/ru/post/1793932/More articles:fwrite puts an error indicator into a stream in C - cHow to set report language in report builder 3.0? - reporting-servicesIs there an available online architecture for e-commerce in java - javaPositional Access Efficiency ArrayList and ArrayList - javaHow to save a link to `std :: cout` as a member of a class - c ++Те же структуры/библиотеки на Node.js и Sproutcore - javascriptIs PCI compatible with image support (secure) not only with another subdomain, but also with a different domain? - htmlIs there a Python alternative for matlab cp2tform and imtransform? - pythonTablesorter configuration headers - jqueryHow to count the number of child nodes in xml root tag in flex? - flexAll Articles