top | item 41692706

(no title)

anon946 | 1 year ago

Only if you let the mistake go unmentioned. I do a version of this where I glibly include a mistake, like:

    // Examples of dereference operator.
    int i, *ip = ..., **ipp = ...;
    i = *ip; // Assuming ip has been correctly initialized.
    i = **ipp; // Likewise.
    // The address-of operator is the opposite.
    ip = &i;
    ipp = &&i;
I actually talk through the last line. Almost no one ever questions it. I then ask students to look at that last line again, and ask them if an address has an address, and if so, what does that mean, could it ever be useful?

discuss

order

mewpmewp2|1 year ago

I see what the mistake is! You are using some sort of gibberish instead of using JavaScript and naming your variables with clear and verbose intent.

coupdejarnac|1 year ago

If this is the lesson where you're introducing pointers to students, you're probably doing them a disservice. Reminds me of my engineering professors who were bored with the material, so they dove straight into difficult problems.