a question of const

Feb 2, 2013 at 9:29pm
What is the difference of the const between Error_code top(Stack_entry &item)const; and Error_code push(const Stack_entry &item); why the first is at the rear and the second is at the front of the item?
Last edited on Feb 3, 2013 at 8:04am
Feb 2, 2013 at 9:42pm
Its the declaration of a constructor for class Queue.
http://www.cplusplus.com/doc/tutorial/classes/
Feb 2, 2013 at 11:21pm
thanks for your response!! can I ask that what the different between the first queue and the second one? why can't I declare class queue just use class queue??thanks
Feb 2, 2013 at 11:47pm
what the different between the first queue and the second one?

The first one specifies that this belongs to the class Queue.
The second declares the constructor.

why can't I declare class queue just use class queue?

You can. You only need to declare (and define) a constructor if you want something in particular to happen when the Queue object is created.

The tutorial page is a starting point, but you will probably need additional study material, such as book(s) in order to get a clearer understanding of the topic.
Feb 3, 2013 at 5:39am
okay, thanks very much!!
Topic archived. No new replies allowed.