Click here to Skip to main content
15,867,686 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Basic C++ - can you explain the difference / function of each definition ? Pin
Richard MacCutchan25-Jan-23 5:21
mveRichard MacCutchan25-Jan-23 5:21 
AnswerRe: Basic C++ - can you explain the difference / function of each definition ? Pin
charlieg28-Jan-23 8:57
charlieg28-Jan-23 8:57 
GeneralMessage Closed Pin
29-Jan-23 3:57
Member 1496877129-Jan-23 3:57 
GeneralRe: Basic C++ - can you explain the difference / function of each definition ? Pin
charlieg1-Feb-23 4:20
charlieg1-Feb-23 4:20 
QuestionQueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
peterchen24-Jan-23 0:34
peterchen24-Jan-23 0:34 
AnswerRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
Richard MacCutchan24-Jan-23 0:44
mveRichard MacCutchan24-Jan-23 0:44 
AnswerRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
CPallini24-Jan-23 2:02
mveCPallini24-Jan-23 2:02 
GeneralRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
Richard MacCutchan24-Jan-23 2:20
mveRichard MacCutchan24-Jan-23 2:20 
GeneralRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
CPallini24-Jan-23 2:32
mveCPallini24-Jan-23 2:32 
AnswerRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
Randor 24-Jan-23 3:49
professional Randor 24-Jan-23 3:49 
GeneralRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
harold aptroot24-Jan-23 8:42
harold aptroot24-Jan-23 8:42 
QuestionRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
Randor 24-Jan-23 9:06
professional Randor 24-Jan-23 9:06 
GeneralRe: QueryThreadCycleTime, QueryProcessCycleTime: what do these number mean? Pin
harold aptroot24-Jan-23 9:26
harold aptroot24-Jan-23 9:26 
QuestionMessage Closed Pin
21-Jan-23 9:57
Member 1496877121-Jan-23 9:57 
AnswerRe: "C++ is static (language)..." Pin
Mircea Neacsu21-Jan-23 10:59
Mircea Neacsu21-Jan-23 10:59 
AnswerRe: "C++ is static (language)..." Pin
Richard MacCutchan21-Jan-23 22:06
mveRichard MacCutchan21-Jan-23 22:06 

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.