Amongst the programming languages I know and those I’ve been exposed to, C++ looks like the only one to have both pointers and references. Is it true?
Amongst the programming languages I know and those I’ve been exposed to, C++ looks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Algol 68 and Pascal certainly do. IIRC, Ada does too, though I don’t remember all the details. PL/I did as well — it may (easily) have been the first to include both.
Algol 68’s references were really more like C++ pointers though. In C++, once you initialize a reference, it always refers to the same object. In Algol 68, you could “reseat” a reference, so it referred to a different object.
It’s been a while since I used Pascal, but if memory serves its only use of references is for parameter passing (i.e. a
varparameter passes by reference). I don’t think you can create a reference other than as a parameter.Ada allows you to mark parameters as
in,out, orinout. If I recall correctly, someinoutparameters are copied into the function, then copied back to the caller at the end, but others are pass by reference. As I said, I don’t remember the details though.