Click here to Skip to main content
16,011,358 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralConstruction fails Pin
Fernando A. Gomez F.14-Oct-04 10:50
Fernando A. Gomez F.14-Oct-04 10:50 
GeneralRe: Construction fails Pin
David Crow14-Oct-04 11:01
David Crow14-Oct-04 11:01 
GeneralRe: Construction fails Pin
Fernando A. Gomez F.14-Oct-04 11:09
Fernando A. Gomez F.14-Oct-04 11:09 
GeneralRe: Construction fails Pin
Fernando A. Gomez F.14-Oct-04 11:16
Fernando A. Gomez F.14-Oct-04 11:16 
GeneralRe: Construction fails Pin
Stan Shannon14-Oct-04 11:02
Stan Shannon14-Oct-04 11:02 
GeneralRe: Construction fails Pin
Fernando A. Gomez F.14-Oct-04 11:11
Fernando A. Gomez F.14-Oct-04 11:11 
GeneralRe: Construction fails Pin
Stan Shannon14-Oct-04 11:20
Stan Shannon14-Oct-04 11:20 
GeneralRe: Construction fails Pin
Joaquín M López Muñoz14-Oct-04 12:00
Joaquín M López Muñoz14-Oct-04 12:00 
Please take into account that calling a constructor inside another constructor is just illegal C++. The fact that it seems to work is just mere luck. C++ does not allow to do this. (Incidentally, this feature is being discussed for inclusion into the next revision of the C++ standard, under the name forward constructor.)

A valid alternative, however, is the following, which uses the so-called placement new:
#include <new> // necessary include if you use placement-new
 
...
 
CTransfer::CTransfer()
{
  new (this) CTransfer(new CTransferFileInfo, NULL);
}
All in all, having a common initialization function, as has been suggested, is probably clearer. Hope this helps.


Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
GeneralRe: Construction fails Pin
Bob Stanneveld14-Oct-04 12:24
Bob Stanneveld14-Oct-04 12:24 
GeneralRe: Construction fails Pin
Joaquín M López Muñoz14-Oct-04 12:32
Joaquín M López Muñoz14-Oct-04 12:32 
GeneralRe: Construction fails Pin
Bob Stanneveld14-Oct-04 12:38
Bob Stanneveld14-Oct-04 12:38 
GeneralRe: Construction fails Pin
Fernando A. Gomez F.14-Oct-04 13:24
Fernando A. Gomez F.14-Oct-04 13:24 
Generalowner draw of list header in IShellView Pin
summit2514-Oct-04 10:40
summit2514-Oct-04 10:40 
QuestionHow to isolate a specific section of a string? [C++] Pin
Shaitan0014-Oct-04 10:21
Shaitan0014-Oct-04 10:21 
AnswerRe: How to isolate a specific section of a string? [C++] Pin
Stan Shannon14-Oct-04 10:46
Stan Shannon14-Oct-04 10:46 
AnswerRe: How to isolate a specific section of a string? [C++] Pin
toxcct14-Oct-04 20:05
toxcct14-Oct-04 20:05 
QuestionHow to determine if a string has a specific character? [C++] Pin
Shaitan0014-Oct-04 10:20
Shaitan0014-Oct-04 10:20 
AnswerRe: How to determine if a string has a specific character? [C++] Pin
Blake Miller14-Oct-04 10:35
Blake Miller14-Oct-04 10:35 
GeneralFull Screen Win32 app Pin
InflatableGarfield14-Oct-04 10:18
InflatableGarfield14-Oct-04 10:18 
GeneralRe: Full Screen Win32 app Pin
22491714-Oct-04 22:36
22491714-Oct-04 22:36 
QuestionDoes VC++.net need .net framework installed? Pin
bitpusher14-Oct-04 9:36
bitpusher14-Oct-04 9:36 
AnswerRe: Does VC++.net need .net framework installed? Pin
Christian Graus14-Oct-04 9:44
protectorChristian Graus14-Oct-04 9:44 
GeneralMessage flow to simulate Copy/Paste Pin
GuimaSun14-Oct-04 8:24
GuimaSun14-Oct-04 8:24 
GeneralRe: Message flow to simulate Copy/Paste Pin
David Crow14-Oct-04 9:54
David Crow14-Oct-04 9:54 
GeneralRe: Message flow to simulate Copy/Paste Pin
Anonymous14-Oct-04 10:38
Anonymous14-Oct-04 10:38 

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.