Saturday, October 27, 2012

Why use references rather than pointers in the public API, particularly for arguments which are modified?


4 :: Why use references rather than pointers in the public API, particularly for arguments which are modified?

The C++ provides the most precise statement of the priciples:
No pointers in the public API, except when returning a pointer which might be null. The above reference also describes the problem of wrong attitudes brought over from C.
anguag� t t i �ď �T� least not for my purposes). A good programming language allows you to think in the language of the problem, not the language of the computer. In C++ you keep having to return to implementational details, such as whether to use a pointer or a reference or a value, a derived class or a template. This is probably unavoidable if good performance is going to be achieved.
But the main reason is a lack of alternatives. Java is (generally) slow, and clumsy in places. Maybe Objective-C, Delphi, or even C# have solved some of these problems, but they are less portable and less widespread than C++.

Earn upto Rs. 9,000 pm checking Emails. Join now!

No comments:

Post a Comment