Hi.

When I was looking at the header files of c library such as malloc.h, I saw that it defines some functions inside the struct (Function Pointer) and other functions outside, so my question is, why sometimes people defining function inside the struct and sometimes outside?

Thanks

--
Mark

Recommended Answers

All 2 Replies

What venomxxl said. Adding to that, in the days before C++ (some of use were doing complex C software development in those dark years), we still understood abstractions, and keeping the association of processing functions close to the data they were intended to process - sort of the antecedent of OOP and C++, and we would do just that, create data structures with pointers to the functions used to process that data. It was clunky, but it worked. Stuff I wrote like that in the 80's still is in use today by industry and the military.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.