'Alias Test in 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?
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | David Grayson |