Click here to Skip to main content
15,900,598 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCcmdtarget() assertion and relaise failure Pin
Zouaoui Billel8-Dec-22 9:00
Zouaoui Billel8-Dec-22 9:00 
AnswerRe: Ccmdtarget() assertion and relaise failure Pin
Victor Nijegorodov8-Dec-22 9:43
Victor Nijegorodov8-Dec-22 9:43 
QuestionProper way to put a C++ object inside a struct initialization? Pin
arnold_w5-Dec-22 1:01
arnold_w5-Dec-22 1:01 
AnswerRe: Proper way to put a C++ object inside a struct initialization? Pin
CPallini5-Dec-22 1:15
mveCPallini5-Dec-22 1:15 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
arnold_w5-Dec-22 2:05
arnold_w5-Dec-22 2:05 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
CPallini5-Dec-22 2:54
mveCPallini5-Dec-22 2:54 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
arnold_w5-Dec-22 3:32
arnold_w5-Dec-22 3:32 
GeneralRe: Proper way to put a C++ object inside a struct initialization? Pin
Mircea Neacsu5-Dec-22 2:54
Mircea Neacsu5-Dec-22 2:54 
The line prohibits compiler from copying MyObject objects.

Look at the following code to better understand what's going on:
C++
namespace MyNamespace
{
class MyObject
{
  int m_i;
public:
  MyObject (int i) :m_i (i + 1) { cout << "MyObject constructor i=" << i << endl; }
  MyObject (const MyObject&) = delete; //these objects cannot be copied
  int get_i () const { return m_i; }
};
}


struct MyStruct
{
  MyStruct (const MyNamespace::MyObject& r) //tell compiler how to build a MyStruct
    : myObject (r.get_i ()) //cannot copy myObject so I just make a new one
    { cout << "MyStruct constructor" << endl; }

  MyNamespace::MyObject  myObject;
};

static MyStruct s_myStruct { MyNamespace::MyObject (5) };
//created a MyObject, then created a second one and finally finished construction of myStruct

// this probably won't run on a microcontroller...
int main ()
{
  cout << s_myStruct.myObject.get_i () << endl;
}
The output is:
MyObject constructor i=5
MyObject constructor i=6
MyStruct constructor
7

Mircea

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

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.