pointers

greenspun.com : LUSENET : AP Computer Science : One Thread

lhs, rhs, *this

how are they used?

-- nancy li (nancy618@yahoo.com), May 07, 2000

Answers

Pointers are basically dynamic memory references which hold the address of a memory location. When an object is instantiated, the object must reside in memory and therefore the starting address of this object must be kept track of. This is done by using the this pointer, which serves as an internal reference for an object to its own memory location. Basically, the this pointer keeps track of the address of an instantiation of a class. It's part of the class, serving as a private identifier, and therefore cannot be accessed outside of the class.

-- Alex Hsi (ahsi@home.com), May 08, 2000.

lhs and rhs stand for left-hand side and right-hand side, respectively. It is commonly used as a substitute for the arguments in an expression, with lhs standing for the argument on the left hand side of the expression and rhs standing for the argument on the right hand side of the expression. The example given in the AP Computer Science case study is that "in the expression if(big==3) the argument big is passed to the parameter lhs and the argument 3 is passed to the parameter rhs."

-- Alex Hsi (ahsi@home.com), May 08, 2000.

Moderation questions? read the FAQ