Click here to Skip to main content
15,797,576 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProper way to put a C++ object inside a struct initialization? Pin
arnold_w5-Dec-22 2:01
arnold_w5-Dec-22 2:01 
AnswerRe: Proper way to put a C++ object inside a struct initialization? Pin
CPallini5-Dec-22 2:15
mveCPallini5-Dec-22 2:15 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
arnold_w5-Dec-22 3:05
arnold_w5-Dec-22 3:05 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
CPallini5-Dec-22 3:54
mveCPallini5-Dec-22 3:54 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
arnold_w5-Dec-22 4:32
arnold_w5-Dec-22 4:32 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
Mircea Neacsu5-Dec-22 3:54
Mircea Neacsu5-Dec-22 3:54 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
CPallini5-Dec-22 8:44
mveCPallini5-Dec-22 8:44 
AnswerRe: Proper way to put a C++ object inside a struct initialization? Pin
Mircea Neacsu5-Dec-22 2:30
Mircea Neacsu5-Dec-22 2:30 
Your code is correct but dangerous. You don’t control the time when myStruct is initialized. There are various methods to control it. My preferred method is the nifty counter[^].

In general, you can include objects in structures. As a matter of fact C++ makes little difference between the two. Without seeing the code, I suspect that your problem is that you don’t have a default constructor for your object. Let me explain: as you don’t have a default constructor for myStruct, the compiler will synthesize one that invokes the default constructor for any included non-trivial members. If your object doesn’t have a default constructor, the compiler complains.
Mircea

GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
arnold_w5-Dec-22 3:07
arnold_w5-Dec-22 3:07 
QuestionMFC. How to display a bitmap or a .png file Pin
BigSteve-O14-Nov-22 9:44
BigSteve-O14-Nov-22 9:44 
QuestionRe: MFC. How to display a bitmap or a .png file Pin
CPallini14-Nov-22 10:25
mveCPallini14-Nov-22 10:25 
AnswerRe: MFC. How to display a bitmap or a .png file Pin
BigSteve-O14-Nov-22 10:57
BigSteve-O14-Nov-22 10:57 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
Victor Nijegorodov14-Nov-22 11:52
Victor Nijegorodov14-Nov-22 11:52 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
BigSteve-O14-Nov-22 12:29
BigSteve-O14-Nov-22 12:29 
QuestionRe: MFC. How to display a bitmap or a .png file Pin
CPallini15-Nov-22 2:58
mveCPallini15-Nov-22 2:58 
AnswerRe: MFC. How to display a bitmap or a .png file Pin
BigSteve-O16-Nov-22 14:45
BigSteve-O16-Nov-22 14:45 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
Victor Nijegorodov16-Nov-22 21:22
Victor Nijegorodov16-Nov-22 21:22 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
Victor Nijegorodov16-Nov-22 21:36
Victor Nijegorodov16-Nov-22 21:36 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
CPallini17-Nov-22 4:02
mveCPallini17-Nov-22 4:02 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
BigSteve-O17-Nov-22 12:31
BigSteve-O17-Nov-22 12:31 
QuestionRe: MFC. How to display a bitmap or a .png file Pin
CPallini17-Nov-22 20:57
mveCPallini17-Nov-22 20:57 
AnswerRe: MFC. How to display a bitmap or a .png file Pin
BigSteve-O18-Nov-22 13:36
BigSteve-O18-Nov-22 13:36 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
Randor 19-Nov-22 10:55
professional Randor 19-Nov-22 10:55 
GeneralRe: MFC. How to display a bitmap or a .png file Pin
BigSteve-O19-Nov-22 12:41
BigSteve-O19-Nov-22 12:41 
QuestionRe: MFC. How to display a bitmap or a .png file Pin
Randor 19-Nov-22 14:39
professional Randor 19-Nov-22 14:39 

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.