Click here to Skip to main content
15,888,286 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: English , please.... Pin
Richard MacCutchan1-Feb-23 21:07
mveRichard MacCutchan1-Feb-23 21:07 
AnswerRe: English , please.... Pin
Calin Negru2-Feb-23 1:03
Calin Negru2-Feb-23 1:03 
AnswerRe: English , please.... Pin
Gerry Schmitz2-Feb-23 6:57
mveGerry Schmitz2-Feb-23 6:57 
GeneralRe: English , please.... Pin
Richard MacCutchan3-Feb-23 1:08
mveRichard MacCutchan3-Feb-23 1:08 
AnswerRe: English , please.... Pin
k50542-Feb-23 9:18
mvek50542-Feb-23 9:18 
QuestionClang/LLVM support in Visual Studio projects Pin
ForNow31-Jan-23 10:25
ForNow31-Jan-23 10:25 
AnswerRe: Clang/LLVM support in Visual Studio projects Pin
Dave Kreskowiak31-Jan-23 10:54
mveDave Kreskowiak31-Jan-23 10:54 
AnswerRe: Clang/LLVM support in Visual Studio projects Pin
Mircea Neacsu31-Jan-23 12:18
Mircea Neacsu31-Jan-23 12:18 
GeneralRe: Clang/LLVM support in Visual Studio projects Pin
ForNow31-Jan-23 12:44
ForNow31-Jan-23 12:44 
GeneralRe: Clang/LLVM support in Visual Studio projects Pin
Mircea Neacsu31-Jan-23 12:54
Mircea Neacsu31-Jan-23 12:54 
GeneralRe: Clang/LLVM support in Visual Studio projects Pin
ForNow31-Jan-23 12:56
ForNow31-Jan-23 12:56 
GeneralRe: Clang/LLVM support in Visual Studio projects Pin
jschell2-Feb-23 7:53
jschell2-Feb-23 7:53 
GeneralRe: Clang/LLVM support in Visual Studio projects Pin
Mircea Neacsu2-Feb-23 8:03
Mircea Neacsu2-Feb-23 8:03 
GeneralRe: Clang/LLVM support in Visual Studio projects Pin
jschell3-Feb-23 5:01
jschell3-Feb-23 5:01 
QuestionInverted linked list in C Pin
Amine Saber28-Jan-23 21:23
Amine Saber28-Jan-23 21:23 
AnswerRe: Inverted linked list in C Pin
Richard MacCutchan28-Jan-23 22:42
mveRichard MacCutchan28-Jan-23 22:42 
QuestionRe: Inverted linked list in C Pin
David Crow29-Jan-23 12:56
David Crow29-Jan-23 12:56 
QuestionMessage Closed Pin
24-Jan-23 10:52
Member 1496877124-Jan-23 10:52 
AnswerRe: Basic C++ - can you explain the difference / function of each definition ? Pin
k505424-Jan-23 11:10
mvek505424-Jan-23 11:10 
GeneralMessage Closed Pin
24-Jan-23 12:09
Member 1496877124-Jan-23 12:09 
GeneralRe: Basic C++ - can you explain the difference / function of each definition ? Pin
k505424-Jan-23 12:32
mvek505424-Jan-23 12:32 
GeneralRe: Basic C++ - can you explain the difference / function of each definition ? Pin
Richard MacCutchan24-Jan-23 23:49
mveRichard MacCutchan24-Jan-23 23:49 
AnswerRe: Basic C++ - can you explain the difference / function of each definition ? Pin
Graham Breach24-Jan-23 11:30
Graham Breach24-Jan-23 11:30 
AnswerRe: Basic C++ - can you explain the difference / function of each definition ? Pin
Richard MacCutchan24-Jan-23 22:26
mveRichard MacCutchan24-Jan-23 22:26 
1. Create an object on the stack
C++
QBluetoothLocalDevice localDevices;

This reserves all the memory space required for a QBluetoothLocalDevice object on the local stack. It then calls the constructor of the class to initialise any parts of that memory as specified in the class (see answers by @k5054). The variable localDevices holds the address of the object (even though it does not appear to be a pointer).

2. Create an object on the dynamic heap, and return a pointer to it.
C++
QBluetoothLocalDevice *localDevices_new =  new QBluetoothLocalDevice();

In this case the memory is requested from the heap, the constructor called to initialise it, and its address returned and saved in the pointer localDevices_new.

The end result is much the same in both cases, apart from the location and lifetime of the two objects. In case 1 the object only exists within the function where it is created; it is automatically destroyed when the function ends. In case 2 the object exists until it is destroyed by the delete statement, or the program terminates.

But as suggested elswhere, this is basic C++, which you should have learned and understood long before you charged down this rabbit hole that you currently find yourself in.
AnswerRe: Basic C++ - can you explain the difference / function of each definition ? Pin
jschell25-Jan-23 5:08
jschell25-Jan-23 5:08 

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.