Ask your own question, for FREE!
Mathematics 21 Online
OpenStudy (christos):

C++, so I have this class https://www.dropbox.com/s/s3ww1xopw5b42xa/Screenshot%202015-11-30%2000.17.34.png?dl=0 can someone please explain to me what is this '&' right here: https://www.dropbox.com/s/5g2tprliy9ji466/Screenshot%202015-11-30%2000.19.11.png?dl=0 thanks

OpenStudy (ikram002p):

& is a pointer just a refrence

OpenStudy (superdavesuper):

are u familiar with the top command? top() - return top item and its syntex is top(StackEntry & item) The item can be anything...or nothing. So in your case, there is nothing to return so it is blank. But the & separator must still be there. Read more from here: ftp://cseftp.tc.uvu.edu/CNS/fairclde/Fall%202009/CS%202420/Slides/chapter%2002%20Object-Oriented%20Data%20Structures.pptx

OpenStudy (ikram002p):

yeah i agree but in general & means a pointer. sometimes it can refer to a location what ever its type integer.. string... or whatever. tight @superdavesuper ?

OpenStudy (superdavesuper):

@ikram002p correct - it is just "something" there available for whatever purpose. in the above linked example: ErrorCode Stack::top(StackEntry & item)const { // Pre: None // Post: If not empty, top item returned // If empty, underflow returned ErrorCode outcome = success; if(count == 0) outcome = underflow; else item = entry[count - 1]; return outcome; }//End top() So item is used to store the previous entry. if necessary...

OpenStudy (christos):

so if I just leave it like this (&) (not &item) will it compile ? also what's that pre and post ?????

OpenStudy (christos):

thanks a lot for answering to me

OpenStudy (superdavesuper):

@Christos it will compile just fine. sorry i didnt see any pre or post in ur codes.

OpenStudy (christos):

I know there weren't , I am just asking cause I see that a lot // Pre: None // Post: .....

OpenStudy (superdavesuper):

sorry i cant tell w/o seeing the codes...

OpenStudy (christos):

here is the code

OpenStudy (christos):

ErrorCode Stack::top(StackEntry & item)const { // Pre: None // Post: If not empty, top item returned // If empty, underflow returned ErrorCode outcome = success; if(count == 0) outcome = underflow; else item = entry[count - 1]; return outcome; }//End top() So item is used to store the previous entry. if necessary...

OpenStudy (superdavesuper):

Oh @Christos i just cut & paste from the example n didnt remember wats in there lol

OpenStudy (superdavesuper):

That whole section: // Pre: None // Post: If not empty, top item returned // If empty, underflow returned contains just comments and explains how the stacks operate ;)

OpenStudy (christos):

Nice slides!!!

OpenStudy (superdavesuper):

pre means before and post means after

OpenStudy (superdavesuper):

yup yup @Christos

OpenStudy (christos):

thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!