Click here to Skip to main content
15,913,101 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAutomating Outlook Pin
ctbmei10-Feb-04 20:13
ctbmei10-Feb-04 20:13 
GeneralRe: Automating Outlook Pin
jmkhael11-Feb-04 0:37
jmkhael11-Feb-04 0:37 
GeneralDynamic display of MSChart Pin
vidyaby10-Feb-04 19:55
vidyaby10-Feb-04 19:55 
GeneralMemory usage for SetWindowText Pin
Coremn10-Feb-04 19:38
Coremn10-Feb-04 19:38 
GeneralArray of Objects of a class Pin
Member 38437310-Feb-04 18:16
Member 38437310-Feb-04 18:16 
GeneralRe: Array of Objects of a class Pin
Maxwell Chen10-Feb-04 19:39
Maxwell Chen10-Feb-04 19:39 
GeneralRe: Array of Objects of a class Pin
Member 38437310-Feb-04 21:54
Member 38437310-Feb-04 21:54 
GeneralRe: Array of Objects of a class Pin
Antti Keskinen10-Feb-04 23:37
Antti Keskinen10-Feb-04 23:37 
One way would be to implement a equality operation (operator=) inside the class, then after you've created the array of new objects, you use the returned pointer to explicitly call the constructor you desire.

For example, consider this:
AA* aa = NULL;<br />
aa = new AA[3];<br />
<br />
aa[0] = AA::AA(5);


This would create a new temporary AA object, initialize it with number 5, then copy it's contents to replace the array's first object. Finally, it destroys the temporary object. If you don't want to write an equality operator, you can always use memory-wise copying.

The last way is to write a new operator New[] for your class. This means that you must explicitly call malloc to reserve memory for your new object. Writing this operator is a tedious work and must be done very carefully to avoid memory leak problems. To use an array declaration, you could possibly implement a variable-length argument list for the operator New[], then get arguments from this list to initialize your objects with...

That requires, however, HARD WORK. The easiest thing to do would just use a member function to initialize the objects.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Array of Objects of a class Pin
Member 38437311-Feb-04 20:10
Member 38437311-Feb-04 20:10 
GeneralObject ID's dont appear in Class Wizard Pin
SJS_OZ10-Feb-04 18:09
SJS_OZ10-Feb-04 18:09 
Generalweb browser customization Pin
Abhi Lahare10-Feb-04 18:05
Abhi Lahare10-Feb-04 18:05 
GeneralRunning VBscript Pin
pranavamhari10-Feb-04 17:21
pranavamhari10-Feb-04 17:21 
GeneralRe: Running VBscript Pin
Ryan Binns10-Feb-04 17:56
Ryan Binns10-Feb-04 17:56 
GeneralVERSIONINFO in program Pin
shultas10-Feb-04 16:09
shultas10-Feb-04 16:09 
GeneralRe: VERSIONINFO in program Pin
pranavamhari10-Feb-04 17:26
pranavamhari10-Feb-04 17:26 
Generalmax controls on a dialog using vc++ Pin
burnafatty10-Feb-04 14:17
burnafatty10-Feb-04 14:17 
GeneralRe: max controls on a dialog using vc++ Pin
John R. Shaw10-Feb-04 14:48
John R. Shaw10-Feb-04 14:48 
GeneralRe: max controls on a dialog using vc++ Pin
Christian Graus10-Feb-04 15:49
protectorChristian Graus10-Feb-04 15:49 
GeneralRe: max controls on a dialog using vc++ Pin
Tim Smith10-Feb-04 18:18
Tim Smith10-Feb-04 18:18 
GeneralRe: max controls on a dialog using vc++ Pin
burnafatty11-Feb-04 7:35
burnafatty11-Feb-04 7:35 
GeneralRe: max controls on a dialog using vc++ Pin
Christian Graus11-Feb-04 9:46
protectorChristian Graus11-Feb-04 9:46 
GeneralRe: max controls on a dialog using vc++ Pin
Ryan Binns10-Feb-04 17:59
Ryan Binns10-Feb-04 17:59 
GeneralThanks Pin
burnafatty11-Feb-04 7:50
burnafatty11-Feb-04 7:50 
GeneralAccessing private class members Pin
georgiek5010-Feb-04 12:54
georgiek5010-Feb-04 12:54 
GeneralRe: Accessing private class members Pin
loket10-Feb-04 13:10
loket10-Feb-04 13:10 

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.