Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alias Test in c++?

Tags:

c++

My professor was going through slides and went across "alias test," saying we should all know what this is, so he will not explain it.

I have never heard of this before, and he refused to explain it, saying I should know what it is by now.

The only thing my classmates and I can find in the course materials is he went over a code snippet in class and said, "The alias test here is used to make sure that the operator= is not used on itself."

Can anyone help to provide some insight on what this is?

like image 567
axil100 Avatar asked Nov 05 '25 10:11

axil100


1 Answers

Aliasing in computer programming means two different variables that point to the same thing. If you are writing your own operator= in your class, you might want to check to make sure the caller did not try to assign an object to itself (e.g. a = a;), since the code in your assignment operator might crash depending on what exactly you are doing. So you might want to test for aliasing in your assignment operator, and the little bit of code that does that could be called an alias test.

like image 74
David Grayson Avatar answered Nov 07 '25 06:11

David Grayson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!