How to structure a C program effectively

后端 未结 7 1436
独厮守ぢ
独厮守ぢ 2020-12-24 12:01

Let me first say that I\'ve got a fair amount of experience in both C and C++. However, I\'m starting a new project in C and I\'ve been working in object-oriented languages

7条回答
  •  情歌与酒
    2020-12-24 12:37

    That's a pretty reasonable way to write a C program. There is another large application out there, which does pretty much the same stuff - called the Linux kernel. Some nearly OO-features used in there:

    • structs and operations on structs for encapsulation just like in your example
    • pointers to base structs as a form of poor man's inheritance -- you'll find loads of references to struct kobject in there
    • macros to generate functions as a replacement for template programming

提交回复
热议问题