Data structure learning (C ++) - preamble

zhaozj2021-02-16  51

Exterior: Previous article called "Labies, stacks, queues (declaration and implementation)" described with C templates, the first time I published a post (I registered for a few days), very immature, changed and changed Don't say, the old longevity is not conducive to reading. So I renounced and I want to make a series, which can be seen from my title. Ok, the words retired.

This article is the preamble of a series of articles, aimed at explaining the purpose of writing, and the style of writing; or gives yourself possible mistakes, pre-give a reference. If you don't want to hear me in this, please skip this article and read the following article directly. But this, I can't guarantee that you will not yell at me while reading.

Why write these articles

These articles can be said to be "data structure (with object-oriented methods and C descriptions)" this book's reading note, but it is not entirely. The data structure is a must-have course of computer professional - almost every computer professional students will advocate him; at the same time, it is also a difficult point in other professional transfer of computer majors.

From the perspective of learning, Yan Weimin "Data (C language version)" is a good book. However, C language is not ideal tool described. "Data Structure (C language version)" is said to: "Although the C language is not an ideal description tool for abstract data types, it is called a reference call from C language in the current and nearly one, two years, ... Parameter transmission mode, etc., constitutes a class C description language. "

Definition from Abstract Data - A mathematical model and a set of operations defined on the model - it can be seen that the concept of object-oriented language is very close to this definition, plus the popularity of C language, using C to describe So it became a matter of success.

So, Tsinghua has changed the "data structure" reference book in 2002, "data structure (using the object-oriented method and C description)" (Yin Kun, etc., ISBN 7-302-03405-2 / TP1845) As a reference, it is actually (nonsense, not that is misleading). Frankly, the original book confuses the purpose of teaching and providing examples. The result is that it is not like: as a textbook, it is unclear; it provides the implementation of each method, it is not very practical, the opposite, repeated construction too much. As for errors, some may be incorrect, such as a few friends declare, not inheritance, the member function of using other classes is not specified; and some, it is not enough to consider it.

No matter what to say, when you are not a book, do you want to take a professional postgraduate student of Captain, this book is your choice. I found the best way to read this book, I'm re-implement various abstract data types in accordance with the idea of ​​the book, and the analysis of practical applications. There is still a benefit to do this, accumulating our wealth in the future.

My writing style

The compiler I chose VC6, so I don't guarantee that the code I offer can also pass in other compilers - only Iostream.h from the head until the end, no other library, of course, there is no MFC, standard C code should have no problem. All is a handmade code, not using ClassWizard, mainly do not like those who are chaotic pretreatment and comments. After that, after the completion of the C declaration and implementation XX.H XX..ccp this document structure is not recruiting - very mess. So I used the structure of single-engineering single CPP, that is, one project has only one CPP file, put main (), and other parts are header files, declarations, and implementation - in fact, this is a violation of C specification, C requirements The function must declare the prototype. In fact, I think this is very rushed (I am a typical C sequelae, I used to use TC to do not declare the prototype, put the function in front of Main (), declare the prototype, I think this And setting your password needs to confirm a truth. Due to the IDE environment used, the declaration is individually concentrated as a file. It has no necessary - ClassView window is easy to use, because of this, I have never seen the statement of the class. Unless you provide a library, a separate declaration file in your project is no longer necessary. Of course, the premise here is to build your project from an empty project. If you use AppWizard, I am hard to imagine that you don't use ClassWizard. Because the structure of the document has been determined, what you do is actually repairing.

Who is suitable for reading these articles

l When you start to transition from C to C , you will experience the new features of C after reading these.

l Studying the people of the yellow book like me, I hope to understand and learn better after reading.

l Never write more than 1,000 lines of code programs so that we can resonate. Because we never use tools and library files, what is done is a stupid thing in programming veterans.

Some agreement

Assume that you are using VC6, first create a Win32 console application Empty Project. Behind this project will be added to this project (that is, it is added to each file introduced later, otherwise do not find XX.h, don't blame each #ifndef xx_h ~ # Endif, and some of them are one head Document, the file name is xx.h. E.g:

#ifndef list_h

#define list_h

......

#ENDIF

This large piece is a file, the file is named list.h

转载请注明原文地址:https://www.9cbs.com/read-23002.html

New Post(0)