[SystemSafety] C++ and Pointers

paul_e.bennett at topmail.co.uk paul_e.bennett at topmail.co.uk
Wed Jun 5 13:08:40 CEST 2019


On 05/06/2019 at 11:37 AM, "Peter Bernard Ladkin" <ladkin at causalis.com> wrote:
>
>There is a chap called Alex, who did his degree at UC Davis and 
>also taught some programming there.
>He has a readable WWW site introducing C++ ,  
>https://www.learncpp.com
>
>It has been a while; I just looked up a couple of things about 
>pointers, in Section 6. Some of the
>things he says - he needs to say - sent shivers up my spine.
>
>He points out that keysymbols "*" and "&" are overloaded. Let's 
>just consider "*". "Although the
>dereference operator looks just like the multiplication operator, 
>you can distinguish them because
>the dereference operator is unary, whereas the multiplication 
>operator is binary."
>
>But that of course is not the only overloading. He goes on to 
>explain declarations, which also use
>keysymbol "*". "int* iPtr"; "int * iPtr"; and "int *iPtr" all have 
>exactly the same meaning.
>However, "int* iPtr1, iPtr2" is not equivalent to "int *iPtr1; int 
>*iPtr2"; but rather to "int
>*iPtr1; int iPtr2".
>
>You need a static analyser just to tell you what your program 
>means!
>
>PBL

Some of the above should also point out the need to provide some form
of in-source documentation that describes what the author intended to
be happening within the functionality of the code. That way, when your
static analyser shows something that is in disagreement with the
author's intentions, the disparity is highlighted most clearly.


Regards

Paul E. Bennett IEng MIET
Systems Engineer
Lunar Mission One Ambassador
-- 
********************************************************************
Paul E. Bennett IEng MIET.....
Forth based HIDECS Consultancy.............
Mob: +44 (0)7811-639972
Tel: Due to relocation - new number TBA. Please use Mobile.
Going Forth Safely ..... EBA. www.electric-boat-association.org.uk..
********************************************************************



More information about the systemsafety mailing list