Click here to Skip to main content
15,922,894 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPossible to retrieve class from <tr class="row1"> using MSHTML? Pin
kumaichi2-Aug-02 6:45
kumaichi2-Aug-02 6:45 
GeneralImportind Dialog to new project Pin
Shay Harel2-Aug-02 6:42
Shay Harel2-Aug-02 6:42 
GeneralRe: Importind Dialog to new project Pin
kumaichi2-Aug-02 6:49
kumaichi2-Aug-02 6:49 
GeneralRe: Importind Dialog to new project Pin
Chris Losinger2-Aug-02 6:52
professionalChris Losinger2-Aug-02 6:52 
GeneralRePainting issues? w/ child controls Pin
Gerjerts2-Aug-02 6:06
Gerjerts2-Aug-02 6:06 
GeneralRandom Linker Error Pin
Zac Howland2-Aug-02 5:53
Zac Howland2-Aug-02 5:53 
GeneralRe: Random Linker Error Pin
Zac Howland2-Aug-02 9:26
Zac Howland2-Aug-02 9:26 
Generalstd::stack questions (2 of them) Pin
Le centriste2-Aug-02 5:36
Le centriste2-Aug-02 5:36 
1- Why doesn't pop() return a reference to the pop()ed object?

It is a pain to always do a top() to get the reference then pop() to remove it. Anyway, I made my own wrapper:

namespace mystd{

/* This class extends std::stack in a way that makes
 * the pop() function return a reference instead of
 * nothing. It is a wrapper around successive calls
 * to top() then pop().
 *
 * It can be used exactly like the std::stack class.
 */
template<class T, class Container = std::deque<T> >
class stack : public std::stack<T, Container> {
public:
	stack() : std::stack<T, Container>() {}
	explicit stack(const container_type& _Cont) : std::stack<T, Container>(_Cont) {}
	virtual ~stack() {}

	// Overriden pop() method.
	T& pop() {
		T& t = top();
		std::stack<T, Container>::pop();

		return t;
	}
};

} // namespace mystd


What do you think of it? Any comment?

2- When you call top() on an empty stack, what happens? The reason I ask this question is because in my wrapper class' pop() method I call top(), then pop(). Is that a problem?

Michel

It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.

- TreeBeard
GeneralRe: std::stack questions (2 of them) Pin
Tomasz Sowinski2-Aug-02 5:51
Tomasz Sowinski2-Aug-02 5:51 
GeneralRe: std::stack questions (2 of them) Pin
Joao Vaz2-Aug-02 5:57
Joao Vaz2-Aug-02 5:57 
GeneralVisual Studio .NET Editor Question! Simple! Pin
Ryan B.2-Aug-02 5:33
Ryan B.2-Aug-02 5:33 
GeneralCTreeCtrl Collapsing Message Pin
jparsons2-Aug-02 5:16
jparsons2-Aug-02 5:16 
GeneralRe: CTreeCtrl Collapsing Message Pin
Nish Nishant2-Aug-02 5:19
sitebuilderNish Nishant2-Aug-02 5:19 
GeneralRe: CTreeCtrl Collapsing Message Pin
jparsons2-Aug-02 5:22
jparsons2-Aug-02 5:22 
GeneralRe: CTreeCtrl Collapsing Message Pin
Nish Nishant2-Aug-02 5:29
sitebuilderNish Nishant2-Aug-02 5:29 
Generalhelp needed...!!! Pin
drmzunlimited2-Aug-02 4:54
drmzunlimited2-Aug-02 4:54 
GeneralRe: help needed...!!! Pin
chq122-Aug-02 5:24
chq122-Aug-02 5:24 
GeneralRe: help needed...!!! Pin
drmzunlimited2-Aug-02 7:56
drmzunlimited2-Aug-02 7:56 
QuestionWhere is MS VRML Viewer ? Pin
yarp2-Aug-02 4:51
yarp2-Aug-02 4:51 
GeneralDialogs without MFC Pin
James Spibey2-Aug-02 4:33
James Spibey2-Aug-02 4:33 
GeneralRe: Dialogs without MFC Pin
Chris Losinger2-Aug-02 4:50
professionalChris Losinger2-Aug-02 4:50 
GeneralRe: Dialogs without MFC Pin
James Spibey2-Aug-02 5:01
James Spibey2-Aug-02 5:01 
GeneralRe: Dialogs without MFC Pin
Joel Lucsy2-Aug-02 8:19
Joel Lucsy2-Aug-02 8:19 
GeneralRe: Dialogs without MFC Pin
James Spibey2-Aug-02 12:27
James Spibey2-Aug-02 12:27 
QuestionHow to trap Command Window that appears on execution of a normal VC++ programme or Application... Pin
Pankaj Singh2-Aug-02 4:22
Pankaj Singh2-Aug-02 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.