Top Forums Programming stl map - could any one explain the o/p Post 302347806 by Corona688 on Wednesday 26th of August 2009 12:30:04 PM
Old 08-26-2009
You create an object with tst(), which is later destroyed.
A temporary copy of it is made for some reason when assigning it to the map, which is later destroyed.
Another copy is created to be stored inside the map, which is later destroyed, and with it, the object.

C++'s structure tends to the redundant copying of the copied copy copies sometimes, so this isn't too suprising.

Last edited by Corona688; 08-26-2009 at 02:42 PM..

7 More Discussions You Might Find Interesting

1. Programming

STL map

Hi there, I am using the STL map and I print the map using: map <string, float> ngram_token_index ; map <string, float>::iterator map_iter ; //read the map ... // print the map for ( map_iter = ngram_token_index.begin() ; map_iter != ngram_token_index.end() ; map_iter++ ) cout << ... (2 Replies)
Discussion started by: superuser84
2 Replies

2. Programming

STL from win

Help me please with STL source code that works on Windows I've found on Inet STL MRU Cache (it compiles fine with Studio 2008), but when trying to build it with Kdevelop (g++ is the compiler) I've got a series of error. One of them I've placed in the source code. If it's important I can post here... (0 Replies)
Discussion started by: Orlando_ua
0 Replies

3. UNIX for Dummies Questions & Answers

c++ stl which rpm?

Hello, I'm using RHEL 5.3, I need to compile C++ code and I'd like to know which rpm contains the STL library. Thanks:) (3 Replies)
Discussion started by: pppswing
3 Replies

4. Programming

which stl is best suited to represent a tree

hi all i have a tree structure: root --- node 1 to node 10 in each node --- sub node 1 to sub node 10 in each sub node --- leaf node 1 to leaf node 10 i have to print this in following fashion: root ---- n1 ---- sn1 ---- l1, l2, l3, ....., l10 n1 ---- sn2 ---- l1, l2, l3,... (2 Replies)
Discussion started by: vidyaj
2 Replies

5. Programming

c++ code to print a tree using stl map

hi all, i need c++ code to print a binary or non binary tree using stl map.... please help me to find the same.......... (1 Reply)
Discussion started by: vidyaj
1 Replies

6. Programming

how to check the value in stl container during debug

Hi, guys. I am working on a project right now. But when I debug my code, I can't see the values in stl container, e.g vector, map. Can anyone help me, please. I am really frustrated:wall:. I am using code::blocks IDE, by the way. Thanks in advance...... (0 Replies)
Discussion started by: tefino
0 Replies

7. Programming

STL transform question

Hi all, I pass to the transform algorithm two vectors, and the suma function. #include <algorithm> #include <iostream> #include <iterator> #include <vector> using namespace std; class Duo{ public: int one; int two; }; Duo suma(Duo first, Duo last){ Duo ret; ... (1 Reply)
Discussion started by: santiagorf
1 Replies
destroy()																 destroy()

  destroy - Object class method called when a widget is destroyed.

  typedef void (*XtWidgetProc)(Widget);
	 Widget w;

  w	    Specifies the widget that is being destroyed.

  The destroy() method is registered on the destroy field of the Object, RectObj, or Core class part structures.  It is invoked by XtDestroy-
  Widget() as part of the destruction process when any widget or object is destroyed, and should deallocate any memory or  resources  associ-
  ated with the part of the widget instance structure specific to this class.  It does not free the widget instance structure itself.

  The  destroy()  methods  of  a  widget  class  and all its superclasses are called in subclass-to-superclass order.  (Note that this is the
  reverse of the usual superclass-to-subclass chaining sequence.) The destroy() method of a widget class should deallocate  memory  or	other
  resources that were explicitly allocated by this class.  Any resource that was obtained from the resource database or passed in an argument
  list was not created by the widget and therefore should not be destroyed by it (unless the widget allocated memory  to  copy	the  resource
  value, in which case the memory must be freed).

  To reclaim memory, at least the following deallocations should be performed:

  o  Call XtFree() on dynamic storage allocated with XtCalloc(), XtMalloc(), etc.

  o  Call XFreePixmap() on pixmaps created with direct Xlib calls.

  o  Call XtReleaseGC() on GCs allocated with XtGetGC().

  o  Call XFreeGC() on GCs allocated with direct Xlib calls.

  o  Call XtRemoveEventHandler() on event handlers added with XtAddEventHandler().

  o  Call XtRemoveTimeOut() on timers created with XtAppAddTimeOut().

  o  Call XtDestroyWidget() for each child if the widget has children and is not a subclass of compositeWidgetClass.

  The  destroy() method is chained, so it cannot be inherited.	If a widget does not need to deallocate any storage, the destroy field in its
  widget class record should be NULL.

  See XtDestroyWidget(1) for details on the process of widget destruction.

  In general, a destroy() method will deallocate any resources allocated in the initialize() and set_values() methods.	This  often  includes
  GCs, pixmaps, and any copies that were made of string resources.

  The  following  procedure is the destroy() method of the Xaw Label widget.  It frees the copy it made of its label string resource, deallo-
  cates two shared GCs, and frees the stipple pixmap it used to draw itself in insensitive mode.

     static void Destroy(w)
	 Widget w;
	 LabelWidget lw = (LabelWidget)w;

	 XtFree( lw->label.label );
	 XtReleaseGC( w, lw->label.normal_GC );
	 XtReleaseGC( w, lw->label.gray_GC);
	 XmuReleaseStippledPixmap( XtScreen(w), lw->label.stipple );

See Also
  Constraint destroy(4), initialize(4), set_values(4).

Xt - Intrinsics Methods 														 destroy()

Featured Tech Videos

All times are GMT -4. The time now is 12:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy