Click here to Skip to main content
15,942,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: AfxRegisterWndClass crashes when called again Pin
Victor Nijegorodov12-Jun-24 20:24
Victor Nijegorodov12-Jun-24 20:24 
GeneralRe: AfxRegisterWndClass crashes when called again Pin
etechX212-Jun-24 21:58
etechX212-Jun-24 21:58 
GeneralRe: AfxRegisterWndClass crashes when called again Pin
Victor Nijegorodov13-Jun-24 5:17
Victor Nijegorodov13-Jun-24 5:17 
GeneralRe: AfxRegisterWndClass crashes when called again Pin
etechX213-Jun-24 18:40
etechX213-Jun-24 18:40 
GeneralRe: AfxRegisterWndClass crashes when called again Pin
Victor Nijegorodov13-Jun-24 19:59
Victor Nijegorodov13-Jun-24 19:59 
QuestionInserting a user defined key in a C++ map Pin
Amrit Agr10-Jun-24 8:23
Amrit Agr10-Jun-24 8:23 
AnswerRe: Inserting a user defined key in a C++ map Pin
Daniel Pfeffer10-Jun-24 8:44
professionalDaniel Pfeffer10-Jun-24 8:44 
QuestionC++, epiphanies, article content ideas Pin
honey the codewitch7-Jun-24 20:28
mvahoney the codewitch7-Jun-24 20:28 
Disclaimer: What I'm about to talk about is C++ implementation details. C++ compilers aren't *necessarily* implemented the way I describe in theory, but in practice they virtually all are - at least the major ones, AFAIK.

C++ is very "lexical" in how it works.

The bones of the OOP, method overloading, and template instantiations are implemented in part through name mangling, which is fundamentally lexical vs having a different, say, integer or binary key for each of the above.

The template instantiations work like a mail merge, but with "smart" template parameters (by smart I mean, not simply lexical but type aware, compiler resolved). The actual template code is basically search and replaced, but template resolution is "smart" (similar to how i used the word above) in that it can resolve recursively and stuff, so it's a bit more complicated than strict search replace, but it's close.

C++ in many ways (but not all ways) is C with syntactic sugar.

C++ OOP isn't special. It's basically C with a combination of name mangling, and hiding the first (implicit) this argument

consider the following

C++
#include <stdio.h>

class foo {
    int m_bar;
public:
    foo(/*foo* this*/) : /*this->*/m_bar(0) {

    }
    int bar(/*foo* this*/) const { return this->m_bar; }
    void bar(/*foo* this, */ int value) { this->m_bar = value; }
};

typedef struct _foo_c {
    int bar;
} foo_c_t;

void foo_foo_foo_c_t(foo_c_t* handle) {
    // : m_bar(0)
    handle->bar = 0;
}
int foo_bar_foo_c_t(foo_c_t* handle) {
    // return this->bar;
    return handle->bar;
}
void foo_bar_foo_c_t_int(foo_c_t* handle, int value) {
    // this->bar = value;
    handle->bar = value;
}

int main(int argc, char** argv) {
    foo foo_cpp;
    foo_cpp.bar(42);

    foo_c_t foo_c;
    foo_foo_foo_c_t(&foo_c);
    foo_bar_foo_c_t_int(&foo_c,42);

    printf("foo_cpp: %d, foo_c: %d\n",foo_cpp.bar(),foo_bar_foo_c_t(&foo_c));

    return 0;
}


That's C++ and its rough equivalent as C code, and the C is similar to how the C++ resolves internally.

I feel like understanding that helped me greatly understand C++.

I'm wondering if any other C++ developers out there had a similar epiphany about the language that helped them understand it better, and what it was.

Part of it is I was thinking of compiling an article about this, but the above isn't enough by itself.

I'm hoping to add more content, but maybe some of you who have had similar epiphanies about the language could inspire more content along this vein. If so, please put it in a reply. Thanks!
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

GeneralRe: C++, epiphanies, article content ideas Pin
k50548-Jun-24 2:10
mvek50548-Jun-24 2:10 
GeneralRe: C++, epiphanies, article content ideas Pin
honey the codewitch8-Jun-24 3:40
mvahoney the codewitch8-Jun-24 3:40 
GeneralRe: C++, epiphanies, article content ideas Pin
trønderen8-Jun-24 5:05
trønderen8-Jun-24 5:05 
AnswerRe: C++, epiphanies, article content ideas Pin
jschell12-Jun-24 14:59
jschell12-Jun-24 14:59 
GeneralRe: C++, epiphanies, article content ideas Pin
honey the codewitch12-Jun-24 15:03
mvahoney the codewitch12-Jun-24 15:03 
GeneralRe: C++, epiphanies, article content ideas Pin
jschell13-Jun-24 12:33
jschell13-Jun-24 12:33 
GeneralRe: C++, epiphanies, article content ideas Pin
honey the codewitch13-Jun-24 12:37
mvahoney the codewitch13-Jun-24 12:37 
GeneralRe: C++, epiphanies, article content ideas Pin
jschell14-Jun-24 13:15
jschell14-Jun-24 13:15 
PraiseI never fail to be impressed by this Pin
honey the codewitch7-Jun-24 5:44
mvahoney the codewitch7-Jun-24 5:44 
QuestionPassing a class (pointer) to library - Linux Pin
Salvatore Terress31-May-24 9:00
Salvatore Terress31-May-24 9:00 
AnswerRe: Passing a class (pointer) to library - Linux Pin
k505431-May-24 10:25
mvek505431-May-24 10:25 
GeneralBUMP Re: Passing a class (pointer) to library - Linux Pin
Salvatore Terress31-May-24 14:12
Salvatore Terress31-May-24 14:12 
GeneralRe: Passing a class (pointer) to library - Linux Pin
Richard MacCutchan1-Jun-24 1:47
mveRichard MacCutchan1-Jun-24 1:47 
GeneralRe: BUMP Re: Passing a class (pointer) to library - Linux Pin
Richard MacCutchan4-Jun-24 2:02
mveRichard MacCutchan4-Jun-24 2:02 
QuestionHow C++ manage memory in event driven system ? Pin
Salvatore Terress30-May-24 4:44
Salvatore Terress30-May-24 4:44 
AnswerRe: How C++ manage memory in event driven system ? Pin
Richard MacCutchan30-May-24 5:47
mveRichard MacCutchan30-May-24 5:47 
AnswerRe: How C++ manage memory in event driven system ? Pin
k505430-May-24 5:58
mvek505430-May-24 5:58 

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.