With f.ex. member functions, in C++ you do: obj->DoSomething(args);
instead of: obj->DoSomething(obj, args);
(In other words, "this" pointer is automatically silently passed in C++)
Yes, I think this is right, and it always seems clunky to me. The leading "obj->" in "obj->DoSomething(obj, args)" is just syntactic sugar to make it look OO when it's really not. Having a function pointer inside a struct only gets us half way there; if the function doesn't "know" anything about the struct in which it is contained without explictly passing in a pointer, then it's not worth much.
Last edited by bison on 19-Feb-2019 at 09:38 PM. Last edited by bison on 18-Feb-2019 at 05:41 PM.
_________________ "Unix is supposed to fix that." -- Jay Miner
I would like to add that from an object point of view, the biggest difference is that C++ allows you to use operators to act on objects, which is not possible in C. This can make using the objects more straightforward.
This has the flip side that you can no longer look at the code and have a gut feeling about what it does in terms of efficiency. Seemingly innocent pointer access or addition may no longer be a rather basic operation with C++, it may instead be a very expensive operation that can do essentially anything, including accessing a file or open a connection over the network.