Click here to Skip to main content
15,921,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCalculate the Array search time in millisecondes Pin
naif6207-Jan-04 5:04
naif6207-Jan-04 5:04 
GeneralRe: Calculate the Array search time in millisecondes Pin
David Crow7-Jan-04 8:49
David Crow7-Jan-04 8:49 
GeneralRe: Calculate the Array search time in millisecondes Pin
naif6208-Jan-04 4:50
naif6208-Jan-04 4:50 
GeneralRe: Calculate the Array search time in millisecondes Pin
David Crow8-Jan-04 6:04
David Crow8-Jan-04 6:04 
QuestionIs this good form? Pin
Cloaca7-Jan-04 4:49
Cloaca7-Jan-04 4:49 
AnswerRe: Is this good form? Pin
Christian Graus7-Jan-04 10:05
protectorChristian Graus7-Jan-04 10:05 
GeneralRe: Is this good form? Pin
Cloaca7-Jan-04 11:53
Cloaca7-Jan-04 11:53 
AnswerRe: Is this good form? Pin
Mike Dimmick8-Jan-04 2:27
Mike Dimmick8-Jan-04 2:27 
It depends whether you want homogeneous (containing one type of object only) or heterogeneous (containing multiple types of object) containers.

If I want a homogeneous container, I typically have the container manage the storage of the contained objects. If the objects are small (perhaps ints), I use a CList< int, int >. If the objects are larger than about 8 bytes, I use CList< T, const T& > so that any functions which need an object (to store it, or compare it) take their argument by constant reference. You don't need to do any extra clean-up when you destroy the container; it destroys all the elements for you.

For a concrete definition of a heterogeneous container, consider a class hierarchy modelling shapes. We have an abstract base class CShape with derived classes CRectangle, CEllipse and CPolygon (for example). We want the container to be able to hold any combination of rectangles, ellipses, polygons and whatever else we might define in future.

To get polymorphic behaviour, we must store base class pointers. So I would normally declare the container as storing pointers of the type of the most-derived base class common to the elements to be contained. In this case I would use a CList< CShape*, CShape* >. The ARGTYPE is a CShape* because pointers are trivial to copy.

Lists of lists are tricky in MFC because CList doesn't define a copy constructor or assignment operator. You can't contain a CList inside a CList (although you can store CList pointers). If the top-level list is heterogeneous, you probably do need to use a list of CObject pointers, and MFC has a special class for that: CObList.
GeneralRe: Is this good form? Pin
Cloaca8-Jan-04 5:02
Cloaca8-Jan-04 5:02 
GeneralRe: Is this good form? Pin
Mike Dimmick8-Jan-04 5:23
Mike Dimmick8-Jan-04 5:23 
GeneralRe: Is this good form? Pin
Cloaca8-Jan-04 11:33
Cloaca8-Jan-04 11:33 
GeneralAdding text display to dialog box Pin
Anonymous7-Jan-04 4:36
Anonymous7-Jan-04 4:36 
GeneralRe: Adding text display to dialog box Pin
valikac7-Jan-04 7:28
valikac7-Jan-04 7:28 
GeneralHelp with HANDLEs Pin
Mortis7-Jan-04 4:14
Mortis7-Jan-04 4:14 
GeneralRe: Help with HANDLEs Pin
Dominik Reichl7-Jan-04 4:33
Dominik Reichl7-Jan-04 4:33 
GeneralRe: Help with HANDLEs Pin
valikac7-Jan-04 7:29
valikac7-Jan-04 7:29 
GeneralFucntion execution time Pin
islheg7-Jan-04 3:49
islheg7-Jan-04 3:49 
GeneralRe: Fucntion execution time Pin
фил7-Jan-04 4:30
фил7-Jan-04 4:30 
GeneralRe: Fucntion execution time Pin
oren frenkel7-Jan-04 6:27
oren frenkel7-Jan-04 6:27 
GeneralRe: Fucntion execution time Pin
Alexander M.,7-Jan-04 10:55
Alexander M.,7-Jan-04 10:55 
GeneralRe: Fucntion execution time Pin
pankajdaga8-Jan-04 3:57
pankajdaga8-Jan-04 3:57 
GeneralRe: Fucntion execution time Pin
islheg10-Jan-04 12:10
islheg10-Jan-04 12:10 
GeneralREMOVE AN ICON Pin
davrodriguez7-Jan-04 3:36
davrodriguez7-Jan-04 3:36 
GeneralRe: REMOVE AN ICON Pin
фил7-Jan-04 3:42
фил7-Jan-04 3:42 
GeneralRe: REMOVE AN ICON Pin
Dominik Reichl7-Jan-04 4:22
Dominik Reichl7-Jan-04 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.