News for hackers. Stuff that matters.
Re:C++ Frequently Questioned Answers (2009) by pipeline_peak on Monday January 24, 2022 @12:55AM (#30054151)
[33.1] Is the type of "pointer-to-member-function" different from "pointer-to-function"?

It’s interesting to notice how “this” is what distinguishes the two.

When creating member functions in C, function pointers are assigned members. In order to access or change the object with an assigned function pointer, that object needs to be called or in other words, “this”.

obj.member_function(&obj);

In C++ would be

obj.member_function();

Re:C++ Frequently Questioned Answers (2009) by BenjiWiebe on Monday January 24, 2022 @02:27AM (#30054532)
People actually put functions in structs in C to make it look like OOP!? That's horrifying!

Or am I (hopefully) misunderstanding something here?

Re:C++ Frequently Questioned Answers (2009) by pipeline_peak on Monday January 24, 2022 @11:25AM (#30059758)
I'm not sure how common it is in practice. CPython and GTK are the most popular examples of OOP in C that I can think of.

It's pretty pointless unless you want some sort of namespace-like organization. Maybe for polymorphism because you can change an instance's "base" member function pointer.