Click here to Skip to main content
16,003,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Qt QtCreator "connect" - need help with lambda C++ syntax Pin
Mircea Neacsu10-Aug-24 9:53
Mircea Neacsu10-Aug-24 9:53 
AnswerRe: SOLVED EDIT / BUMP Qt QtCreator "connect" - need help with lambda C++ syntax Pin
Richard MacCutchan10-Aug-24 21:19
mveRichard MacCutchan10-Aug-24 21:19 
QuestionDELETED Please help me (with) improving my coding skill(s) - how to access iterated object. Pin
jana_hus8-Aug-24 6:41
jana_hus8-Aug-24 6:41 
SuggestionRe: Please help me (with) improving my coding skill(s) - how to access iterated object. Pin
David Crow8-Aug-24 7:37
David Crow8-Aug-24 7:37 
QuestionInheritance and arrays Pin
Calin Negru8-Aug-24 0:49
Calin Negru8-Aug-24 0:49 
AnswerRe: Inheritance and arrays Pin
Mircea Neacsu8-Aug-24 0:58
Mircea Neacsu8-Aug-24 0:58 
GeneralRe: Inheritance and arrays Pin
Calin Negru8-Aug-24 4:28
Calin Negru8-Aug-24 4:28 
AnswerRe: Inheritance and arrays Pin
Richard MacCutchan8-Aug-24 1:01
mveRichard MacCutchan8-Aug-24 1:01 
Yes, it is possible with correct casting, if you are just storing pointers. But you still need to know what type each entry is next time you refer to them. Also the line &LUnits[1] = S; is incorrect, you do not need the leading & character. So you can store them with something like:
C++
soldier * S = new soldier();
LUnits[0] = dynamic_cast<unit*>(S);
sailor* AB = new sailor();
LUnits[1] = dynamic_cast<unit*>(AB);

// and then sometime later

sailor* tar = dynamic_cast<sailor*>(LUnits[1]);

// but if you do 
soldier* squaddie = dynamic_cast<soldier*>(LUnits[1]);
// you have a pointer that is incorrect


[edit]
@Mircea-Neacsu provides a clearer explanation above.

[/edit]

modified 8-Aug-24 8:51am.

GeneralRe: Inheritance and arrays Pin
Mircea Neacsu8-Aug-24 2:31
Mircea Neacsu8-Aug-24 2:31 
GeneralRe: Inheritance and arrays Pin
Richard MacCutchan8-Aug-24 2:50
mveRichard MacCutchan8-Aug-24 2:50 
GeneralRe: Inheritance and arrays Pin
Calin Negru8-Aug-24 4:30
Calin Negru8-Aug-24 4:30 
GeneralRe: Inheritance and arrays Pin
Richard MacCutchan8-Aug-24 4:34
mveRichard MacCutchan8-Aug-24 4:34 
QuestionNotes in MFC/Win32 App Pin
john56326-Aug-24 4:34
john56326-Aug-24 4:34 
AnswerRe: Notes in MFC/Win32 App Pin
Richard MacCutchan6-Aug-24 4:36
mveRichard MacCutchan6-Aug-24 4:36 
AnswerRe: Notes in MFC/Win32 App Pin
Maximilien6-Aug-24 7:38
Maximilien6-Aug-24 7:38 
QuestionEnumerations Pin
Calin Negru5-Aug-24 23:32
Calin Negru5-Aug-24 23:32 
AnswerRe: Enumerations Pin
Victor Nijegorodov5-Aug-24 23:38
Victor Nijegorodov5-Aug-24 23:38 
GeneralRe: Enumerations Pin
Calin Negru6-Aug-24 1:21
Calin Negru6-Aug-24 1:21 
QuestionVoluntarily DELETED - wrong forum Pin
jana_hus4-Aug-24 17:24
jana_hus4-Aug-24 17:24 
AnswerRe: Qt mdiArea - how to "connect" between subwindow (object) ? Pin
k50544-Aug-24 6:31
mvek50544-Aug-24 6:31 
GeneralRe: Qt mdiArea - how to "connect" between subwindow (object) ? Pin
Dave Kreskowiak4-Aug-24 11:35
mveDave Kreskowiak4-Aug-24 11:35 
AnswerRe: Qt mdiArea - how to "connect" between subwindow (object) ? Pin
Dave Kreskowiak4-Aug-24 6:33
mveDave Kreskowiak4-Aug-24 6:33 
GeneralRe: Qt mdiArea - how to "connect" between subwindow (object) ? Pin
Richard MacCutchan5-Aug-24 0:24
mveRichard MacCutchan5-Aug-24 0:24 
Questiondialog update Pin
wa!72-Aug-24 18:28
wa!72-Aug-24 18:28 
AnswerRe: dialog color Pin
OriginalGriff2-Aug-24 18:32
mveOriginalGriff2-Aug-24 18:32 

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.