In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to realize object-oriented thinking with C language". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1, basic information
It is well known that C language is a structured and modular, process-oriented programming language, where users create procedures or functions to perform their tasks. A process-oriented language is easy to learn because it follows the algorithm to execute your statements. To develop a program in a process-oriented language, you need to draw / write algorithms and start converting them into programs or functions.
Because of the process-oriented language feature of C language. When dealing with smaller programs, programmers are more comfortable with the C language. However, when the problem is more complex and the scale of the program is relatively large, the structured programming method shows its deficiency. The designer of the C program must carefully design every detail of the program, taking into account exactly what happens every time the program is running, such as how the values of each variable change, when and which inputs should be made. what should be output on the screen and so on. This demand for programmers is relatively high, if faced with a complex problem, programmers often feel powerless.
Using C language for program design and development, generally embedded devices, such as: refrigerator system, air conditioning system, automotive electronics and so on. In these demand scenarios, the hardware resources are often limited and the memory resources are limited, so using C++ language to design will lead to a large amount of memory resources.
Therefore, in order to make up for the lack of object-oriented attributes of C language, combined with the advantage of small occupation of C program resources. In this paper, a C programming method and system based on object-oriented idea is designed.
2. Interpretation of terms:
Linux:Linux is a free-to-use and free-spread Unix-like operating system. It is a multi-user, multi-task, multi-threaded and multi-CPU operating system based on POSIX and UNIX. It runs major UNIX tools, applications, and network protocols. It supports 32 bit and 64 bit hardware. Linux inherits the design idea of Unix with network as the core, and is a multi-user network operating system with stable performance.
3, key words
Object-oriented, programming
4, technical field to which it belongs
This paper deals with a set of template method and system for c language software design, which is based on linux embedded operating system and supports tailored, configurable and dynamic configuration. So as to improve the development efficiency of the system, the convenience of system maintenance and the stability of system operation.
5. Detailed technical solution description
In order to make up for the deficiency of structured process design, object-oriented, a popular programming concept and design norm, arises at the historic moment. The idea is that everything is the object and the human mode of thinking is used to solve the problem. For example, Python, C++, Objective-C, Smalltalk, Delphi, Java, Swift, C#, Perl, Ruby and so on, among which C++ embedded device programming is widely used. C++ can be regarded as a superset of C, retaining almost all the characteristics of C, and can directly operate hardware registers and other hardware devices. At the same time, it also supports object-oriented and generic programming, which makes C++ super complex. C++ complexity, for programming language learners is simply a nightmare, in the process of learning, lost in the C++ grammar "sea".
However, in the actual production activities, we need to make a variety of combinations of objects, and the objects themselves will be quite different according to the different products. For example, a car manufacturer needs to produce different types of cars, and its engines may come from Mercedes-Benz, BMW, Cosworth and so on. Tires may come from Michelin, Goodyear, Pirelli and so on. This is shown in the following figure.
Therefore, considering the complexity of real-world problems and the requirements of production activities, we need to add the function of configuration to configure objects.
The purpose of this paper is to provide a C language programming template. Based on the idea of object-oriented encapsulation, the functional modules are abstracted and encapsulated, and the configuration functions are integrated to realize the clippable and configurable functions. When designing complex programs, programmers can quickly and efficiently implement a set of programs with good compatibility and high stability. This programming template only contains encapsulation in object-oriented, inheritance and polymorphism, and does not have the function of inheritance and polymorphism.
This design template includes a configuration template, an object template and an initialization template.
The object template is as follows:
The configuration template is as follows:
Whether the configuration template is supported or not must be supported in this template. Others can add its own configuration as needed.
The initialization template is as follows:
From the figure, we can see that the object_create () template will read whether the obj is supported in the configuration formed by the configuration template. If so, get other configurations, assign different obj callback interfaces according to different configurations, and then create an object template to form the real object.
Other interfaces can use this object to call the object interface to achieve object-oriented programming.
How to use objects? Please look at the picture below.
We can see that according to different configurations, users can eat different kinds of rice, if it is rice configuration, users can eat rice.
6. Summary
Using this way of encapsulation + configuration, we can achieve rapid development work, encapsulate the specific content, and improve the development efficiency of the team. Developers do not need to pay attention to the implementation process of other personnel, but only need to call methods.
This is the end of the content of "how to realize object-oriented thinking with C language". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.