Click here to Skip to main content
14,741,682 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How do I convert my C++ function pointer to a C function pointer? Pin
Mircea Neacsu28-Sep-20 7:14
mvaMircea Neacsu28-Sep-20 7:14 
QuestionEmbedded C program Pin
Parth Akshay Barange22-Sep-20 23:27
MemberParth Akshay Barange22-Sep-20 23:27 
SuggestionRe: Embedded C program Pin
Graham Breach22-Sep-20 23:59
MemberGraham Breach22-Sep-20 23:59 
AnswerRe: Embedded C program Pin
Richard MacCutchan23-Sep-20 0:40
mveRichard MacCutchan23-Sep-20 0:40 
AnswerRe: Embedded C program Pin
CPallini23-Sep-20 2:12
mveCPallini23-Sep-20 2:12 
AnswerRe: Embedded C program Pin
Victor Nijegorodov23-Sep-20 9:42
MemberVictor Nijegorodov23-Sep-20 9:42 
AnswerRe: Embedded C program Pin
Dave Kreskowiak23-Sep-20 10:20
mveDave Kreskowiak23-Sep-20 10:20 
QuestionWhy isn't the copy constructor called Pin
Mircea Neacsu22-Sep-20 15:59
mvaMircea Neacsu22-Sep-20 15:59 
I feel I'm turning slightly mad. In my mind the two variants below should give the same output:
class A {
public:
  A () { cout << "A created" << endl; }
};

class B {
public:
  B () { cout << "Default B constructor" << endl; }
  B (A oa) { cout << "B created from A" << endl; }
  B (const B& other) { cout << "B copy constructor" << endl; }
};
int main()
{
  A aobj;
  B* bptr = new B (B (aobj));

  cout << "--------" << endl;

  B bobj (aobj);
  B* bbptr = new B (bobj);
}

After A is created, I create a B from A and then I copy the B using the copy constructor. At least that's my intention.

However the output I get is:
A created
B created from A
--------
B created from A
B copy constructor


What am I missing here?
Mircea

AnswerRe: Why isn't the copy constructor called Pin
_Flaviu22-Sep-20 20:48
Member_Flaviu22-Sep-20 20:48 
GeneralRe: Why isn't the copy constructor called Pin
Mircea Neacsu23-Sep-20 2:45
mvaMircea Neacsu23-Sep-20 2:45 
AnswerRe: Why isn't the copy constructor called Pin
Richard MacCutchan23-Sep-20 0:38
mveRichard MacCutchan23-Sep-20 0:38 
GeneralRe: Why isn't the copy constructor called Pin
Mircea Neacsu23-Sep-20 2:56
mvaMircea Neacsu23-Sep-20 2:56 
AnswerRe: Why isn't the copy constructor called - Solved Pin
Mircea Neacsu23-Sep-20 3:56
mvaMircea Neacsu23-Sep-20 3:56 
GeneralRe: Why isn't the copy constructor called - Solved Pin
Richard MacCutchan23-Sep-20 4:01
mveRichard MacCutchan23-Sep-20 4:01 
GeneralRe: Why isn't the copy constructor called - Solved Pin
Greg Utas24-Sep-20 2:00
mvaGreg Utas24-Sep-20 2:00 
GeneralRe: Why isn't the copy constructor called - Solved Pin
Mircea Neacsu24-Sep-20 3:51
mvaMircea Neacsu24-Sep-20 3:51 
GeneralRe: Why isn't the copy constructor called - Solved Pin
Greg Utas24-Sep-20 4:20
mvaGreg Utas24-Sep-20 4:20 
Questioncompilers for pure assembly code Pin
CalinNegru(fearless_)19-Sep-20 1:46
MemberCalinNegru(fearless_)19-Sep-20 1:46 
AnswerRe: compilers for pure assembly code Pin
Richard MacCutchan19-Sep-20 3:24
mveRichard MacCutchan19-Sep-20 3:24 
AnswerRe: compilers for pure assembly code Pin
Joe Woodbury22-Sep-20 12:38
professionalJoe Woodbury22-Sep-20 12:38 
AnswerRe: compilers for pure assembly code Pin
CalinNegru(fearless_)24-Sep-20 2:00
MemberCalinNegru(fearless_)24-Sep-20 2:00 
QuestionWhy do I get "undefined reference to..." when trying to call a C-function inside a .cpp-file? Pin
arnold_w10-Sep-20 5:54
Memberarnold_w10-Sep-20 5:54 
AnswerRe: Why do I get "undefined reference to..." when trying to call a C-function inside a .cpp-file? PinPopular
Richard MacCutchan10-Sep-20 6:30
mveRichard MacCutchan10-Sep-20 6:30 
QuestionIcons for Executable Files - SOLVED Pin
Richard Andrew x649-Sep-20 15:55
professionalRichard Andrew x649-Sep-20 15:55 
QuestionWhat's the closest thing to an anonymous struct/array I can achieve that compiles with GCC? Pin
arnold_w9-Sep-20 9:16
Memberarnold_w9-Sep-20 9:16 

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.