When was the c language developed? §1 General information about the language

C++ (read c-plus-plus) is a compiled, statically typed general-purpose programming language in which you can create programs of any level of complexity.
For more than 20 years, this language has been among the three most popular and in-demand programming languages. (You can verify this by visiting the TIOBE website).
The language originated in the early 1980s, when Bell Labs employee Björn Stroustrup came up with a number of improvements to the C language for his own needs.

Bjarne Stroustrup – creator of the C++ language

Stroustrup decided to extend the C language with the capabilities found in the Simula language. C language being basic language The UNIX system on which Bell computers ran is fast, feature-rich, and portable. Stroustrup added the ability to work with classes and objects. As a result practical problems simulations turned out to be feasible to solve both in terms of development time (thanks to the use of Simula-like classes) and in terms of computation time (thanks to the speed of C).
Here's how the language developer himself talks about it:



In 1998, the first language standard, known as C++98, was published by a standards committee. C++ continues to evolve to respond modern requirements. One of the groups developing the C++ language and submitting proposals for improving it to the C++ Standards Committee is Boost, which is engaged, among other things, in improving the capabilities of the language by adding metaprogramming features to it. The latest standard was released in 2017 and is called C++17. The next standard will not be long in coming and is expected to appear in 2020.
Nobody owns the rights to the C++ language; it is free. In March 2016, Russia was created working group RG21 C++. The group was organized to collect proposals for the C++ standard, send them to a committee and defend them at general meetings of the International Organization for Standardization.
C++ is a multi-paradigm language (from the word paradigm - writing style computer programs), including a wide range various styles and programming technologies. It is often classified as an object-oriented language, but strictly speaking, this is not the case. During the work process, the developer receives absolute freedom in choosing tools so that the problem solved using a particular approach is solved as efficiently as possible. In other words, C++ does not force the programmer to adhere to only one style of program development (for example, object-oriented).
C++ has a rich standard library that includes common containers and algorithms, I/O, regular expressions, multithreading support, and other features. C++ has influenced many programming languages, including: Java, C#, D. Since C++ belongs to a family of languages ​​based on the syntax of the C language, you can easily master other programming languages ​​of this family: JavaScript, PHP, Perl, Objective-C and many others . etc., including the parent language itself - C. ()
During its existence, the C++ language has acquired persistent myths that are easily refuted (see here: Part 1 and Part 2)

History of the language and standards release

  • 1983
  • creator of the language - Björn Stroustrup, a Bell Labs employee, introduced an early version of the C++ language (“C with classes”)

  • 1985
  • first commercial release of C++, the language gains modern name

  • 1986
  • release of the first edition of The C++ Programming Language - a book dedicated to C++, written by Björn Stroustrup

  • 1998
  • The international standard for the C++ language has been ratified: ISO/IEC 14882:1998 “Standard for the C++ Programming Language"

  • 2003
  • 2005
  • Library Technical Report 1 (TR1) released. While not officially part of the standard, the report described extensions to the standard library that should be included in the next version of the C++ language.

  • 2011
  • release of a new standard – C++11 or ISO/IEC 14882:2011; new standard included additions to the language core and expansion of the standard library, including most of TR1

  • 2014
  • release of the C++14 standard (“International Standard ISO/IEC 14882:2014(E) Programming Language C++”); C++14 can be seen as a small extension over C++11, containing mostly bug fixes and minor improvements

  • 2017
  • release of a new standard – C++1z (C++17). This standard introduced many changes and additions. For example, STD included libraries of the C11 standard, file system, based on boost::filesystem, most of experimental library TS I.

C++ Philosophy

In his book The Design and Evolution of C++ (2007), Björn Stroustrup describes the principles he followed when designing C++ (abbreviated):

  • Get universal language with static data types, the efficiency and portability of the C language.
  • Directly and comprehensively support a variety of programming styles.
  • Give the programmer freedom of choice, even if it gives him the opportunity to choose wrongly.
  • Maintain compatibility with C as much as possible, thereby making it possible easy transition from C programming.
  • Avoid discrepancies between C and C++: any construct that is valid in both languages ​​must mean the same thing in each of them and lead to the same program behavior.
  • Avoid features that are platform dependent or not universal.
  • “Don’t pay for what you don’t use” - no linguistic device should not reduce the performance of programs that do not use it.
  • Do not require an overly complicated programming environment.

C and C++

The syntax of C++ is inherited from the C language. Although, formally, one of the principles of C++ remains maintaining compatibility with the C language, in fact, the standardization groups for these languages ​​do not interact, and the changes they make not only do not correlate, but often fundamentally contradict each other ideologically. Thus, the elements that the new C standards add to the kernel are in the C++ standard elements of the standard library and are not in the kernel at all, for example, dynamic arrays, arrays with fixed boundaries, parallel processing facilities. According to Stroustrup, combining the development of these two languages ​​would be of great benefit, but it is unlikely to be possible for political reasons. So practical compatibility between C and C++ will gradually be lost.
IN in this example, depending on the compiler used, either “C++” or “C” will be output:

#include int main() ( printf("%s\n", (sizeof("a") == sizeof(char)) ? "C++" : "C"); return 0; )

This is due to the fact that character constants in C are of type int , and in C++ - type char, but the sizes of these types vary.

Application Lifecycle Models

Life cycle software is a period of time that begins from the moment a decision is made about the need to create software product and ends at the moment of its complete withdrawal from service. This cycle is the process of building and developing software. There are several models life cycle.
Cascade model life cycle (English waterfall model) was proposed in 1970 by Winston Royce. It provides for the sequential implementation of all stages of the project in strict fixed order. The transition to the next stage means the complete completion of work at the previous stage. The requirements defined at the stage of requirements formation are strictly documented in the form terms of reference and are recorded for the entire development of the project. Each stage culminates in the release of a complete set of documentation sufficient to allow development to be continued by another development team.
Project stages according to the waterfall model:

  1. Formation of requirements;
  2. Design;
  3. Implementation;
  4. Testing;
  5. Implementation;
  6. Operation and maintenance.

In the cascade model, the transition from one project phase to another assumes that the result of the previous phase is completely correct. IN large projects this is almost impossible to achieve. Therefore, this model is only suitable for developing a small project. (W. Royce himself did not adhere to this model and used an iterative model).
Iterative model
An alternative to the cascade model is the iterative and incremental development (IID) model, which received from T. Gilb in the 70s. name of the evolutionary model. The IID model involves breaking the project life cycle into a sequence of iterations, each of which resembles a “mini-project”, including all development processes applied to the creation of smaller pieces of functionality compared to the project as a whole. The goal of each iteration is to obtain a working version of the software system, including functionality defined by the integrated content of all previous and current iterations. The result of the final iteration contains all the required functionality of the product. Thus, with the completion of each iteration, the product receives an increment - an increment - to its capabilities, which, therefore, develop evolutionarily.

Standardization of the application life cycle in Russia

The state standard describes in detail the application life cycle in GOST R ISO/IEC 12207-2010 " Information technology. System and software engineering. Software life cycle processes". This standard is accepted Federal agency on technical regulation and metrology of the Russian Federation and is similar to the international standard ISO/IEC 12207:2008. This standard establishes general structure processes of the software life cycle, which can be guided by in the software industry. The standard does not propose a specific life cycle model. Its provisions are common to any life cycle models, methods and technologies for software creation. It describes the structure of life cycle processes without specifying how to implement or complete the activities and tasks included in those processes.

Development Process – Rational Unified Process (RUP)

Various variants of the iterative approach are implemented in most modern development methodologies:

Rational Unified Process (RUP)(rational unified process) is a software development methodology maintained by Rational Software (IBM). The methodology provides recommendations for all stages of development: from business modeling to testing and commissioning finished program. The Unified Modeling Language (UML) is used as a modeling language.
The complete product development life cycle consists of four phases, each of which includes one or more iterations.

  • Initial stage (Inception)
  • Determining the scope of the project and the amount of resources required. The basic requirements, limitations and key functionality of the product are determined. Risks are assessed. Action planning. When completed initial phase The achievement of the Lifecycle Objective Milestone is assessed, which presupposes an agreement between stakeholders to continue the project.

  • Clarification
  • Documenting requirements. Design, implementation and testing of executable architecture. Clarification of terms and costs. Reducing key risks. Successful completion of the development phase means reaching the Lifecycle Architecture Milestone.

  • Construction
  • In the “Build” phase, most of the product’s functionality is implemented: the application design is completed, the source code is written. The Build phase ends with the first external release of the system and the Initial Operational Capability milestone.

  • Introduction
  • In the “Implementation” phase, the final version of the product is created and transferred from the developer to the customer. This includes a beta testing program, user training, and determining the quality of the product. In case the quality does not meet user expectations or the criteria set in the Start phase, the Implementation phase is repeated again. Completing all goals means achieving the Product Release milestone and completing the full development cycle.


Conversation with Bjarne Stroustrup


Online conference for developers using Embarcadero C++Builder. The conversation with Bjarne Stroustrup, the legendary creator of the C++ language, was conducted by David Intersimone, Embarcadero's vice president of developer relations. (Dubbed translation).

C language(read "C") was created in the early 70s, when Ken Thompson and Dennis Ritchie from Bell Labs developed operating system UNDC. They first created part of the C compiler, then used it to compile the rest of the compiler WITH and finally used the resulting compiler to compile UNIX. The UNIX operating system was originally distributed in source code to WITH among universities and laboratories, and the recipient could compile the C source code into machine code using a suitable C compiler.

The distribution of source code made the UNIX operating system unique; the programmer could change the operating system, and the source code could be transferred from one hardware platform to another. Today the POSIX standard defines standard set UNIX system calls available in WITH, which must be implemented in versions of UNIX that are POSIX-compliant. WITH was the third language developed by Thomson and Ritchie during the creation of UNIX; the first two were, of course, A And IN.

Compared to more early language- BCPL, WITH has been improved by adding data types of specific lengths. For example, data type int could be used to create a variable with a certain number bits (typically 16), while the data type long could be used to create an entire variable with a large number bits (usually 32). Unlike other languages high level, WITH could work with memory addresses directly using pointers and references. Because the WITH retained the ability to directly access hardware, it is often classified as a mid-level language or jokingly called a “mobile assembly language.”

As for grammar and syntax, then WITH is structural language programming. While many modern programmers think in terms of classes and objects, programmers WITH think in terms of procedures and functions. IN WITH you can define your own abstract data types using the keyword struct. Similarly, you can describe your own integer types (enumerations) and give other names existing types data using keyword typedef. In this sense WITH is a structured language with the germs of object-oriented programming.

Wide use C language on various types computers (sometimes called hardware platforms) have unfortunately led to many variations of the language. They were similar, but incompatible with each other. This was a major problem for software developers who needed to write compatible programs that could run on multiple platforms. It became clear that it was necessary standard version C. In 1983 ANSI (American National Standards Committee) formed technical committee X3J11 to create a language standard C(to "provide an unambiguous and machine-independent definition of the language"). In 1989 the standard was approved. ANSI has collaborated with ISO ( International Organization Standards) to standardize C internationally; a joint standard was published in 1990 and named ANSI/ISO 9899:1990. This standard is still being improved and is supported by most compiler development companies.

Bjarne Stroustrup unleashed object-oriented potential WITH by transferring class capabilities Simula 67 V WITH. Initially new language bore the name "With classes" and only then began to be called C++. Language C++ achieved popularity after being developed at Bell Labs, it was later transferred to other industries and corporations. Today it is one of the most popular languages programming in the world. C++ inherits both good and bad sides WITH.

Bjarne Stroustrup: "I came up with C++, wrote down its initial definition, and completed its first implementation. I selected and formulated design criteria C++, developed its main features and was responsible for the fate of proposals for expanding the language in the standardization committee C++", writes the author of the most popular programming language. - " C++ language owes a lot to language C, and language C remains a subset C++ language(but C++ has fixed several serious flaws in the C type system). I also saved funds C, which are low-level enough to handle the most critical system tasks. C language, in turn, owes a lot to its predecessor, BCPL; By the way, the comment style // was taken into C++ from BCPL. The other main source of inspiration was the Simula67 language. The concept of classes (with derived classes and virtual functions) was borrowed from it. The facility for operator overloading and the ability to place declarations anywhere an instruction can be written is reminiscent of Algol68. "

Name C++ invented by Rick Massitti. The name indicates the evolutionary nature of the transition to it from C. "++" is the increment operator in C. The slightly shorter name of C+ is syntax error; in addition, it has already been used as the name of a completely different language. C semantics scholars find that C++ worse than ++C. The language was not named D because it is an extension of C and does not attempt to cure problems by throwing out various features...

Initially C++ programming language was designed so that the author and his friends do not have to program in assembly language, C or other modern languages high level. Its main purpose was to write good programs simpler and more enjoyable for the individual programmer. Development Plan C++ never existed on paper; design, documentation and implementation moved simultaneously. Of course, the external interface C++ was written in C++. There has never been a "C++ Project" or a "C++ Development Committee". That's why C++ has evolved and continues to evolve in all directions to cope with the challenges faced by users and through discussions between the author and his friends and colleagues.

IN C++ language The principles of object-oriented programming are fully supported, including the three pillars on which it stands: encapsulation, inheritance and polymorphism. Encapsulation in C++ supported through the creation of non-standard (custom) data types called classes. C++ language supports inheritance. This means that you can declare new type data (class), which is an extension of an existing one.

Although C++ programming language is rightly called a continuation of C and any workable C program will be supported C++ compiler, in the transition from C to C++ a very significant leap was made. C++ language has benefited from its affinity with the C language for many years, as many programmers have found that in order to take full advantage C++ language, they need to abandon some of their previous knowledge and acquire new ones, namely: study new way conceptualization and programming problem solving. Before you start learning C++, Stroustrup and most other programmers using C++ They consider learning C to be optional.

C++ programming language is currently considered the dominant language used to develop commercial products, 90% of games are written in C++ using DirectX.

Literature:
H.M.Deitel, P.J.Deitel "How to Program in C++"
Bjarne Stroustrup "The C++ Programming Language. 3rd Edition."
Simon Robinson, Ollie Cornes, Jay Glynn and others. "C# for professionals"
Jess Liberty "Teach yourself C++ in 21 days"
Stanislav Gornakov "DirectX, programming lessons in C++"

What is the reason for this status of the C language? Historically, this language is inseparable from the Unix operating system, which is now experiencing its rebirth. The 60s were the era of the formation of operating systems and high-level programming languages. At that time, OSs and compilers were independently developed for each type of computer, and often even their own programming languages ​​(remember, for example, PL/I). At the same time, the commonality of the problems arising in this case has already become obvious. The response to the awareness of this commonality was an attempt to create a universal mobile operating system, and for this it was necessary to have an equally universal and mobile language programming. C became such a language, and Unix became the first OS written almost entirely in a high-level language.

The close connection with Unix gave the C language a testing ground that no other language had at that time. Tasks system programming were rightfully considered at that time the most complex in the industry. For the most part, they were so machine-dependent that many did not even think of solving them differently than in assembler. High-level languages ​​were intended for application programming and only implemented very limited functions necessary for system work, and often only for a certain type of machine.

From the very beginning, the C language was created so that you could write in it system tasks. The creators of C did not develop an abstract model of the language executor, but simply implemented in it those capabilities that were most needed in the practice of system programming. These were primarily means of direct work with memory, structural control structures and modular organization of the program. And essentially nothing else was included in the language. Everything else was put into the runtime library. Therefore, detractors sometimes refer to the C language as a structural assembler. But no matter what they said, the approach turned out to be very successful. Thanks to him it was achieved new level in terms of the simplicity and capabilities of the language.

There is, however, one more factor that determined the success of the language. The creators very skillfully separated in it machine-dependent and independent properties. Thanks to this, most programs can be written universally - their performance does not depend on the processor and memory architecture. A few hardware-dependent parts of the code can be localized in separate modules. And using a preprocessor, you can create modules that, when compiled on different platforms, will generate the corresponding machine-dependent code.

The syntax of the C language has caused a lot of controversy. The shortening techniques used in it, if used excessively, can make the program completely unreadable. But, as Dijkstra said, the means are not to blame for the fact that they are used illiterately. In fact, the syntax abbreviations proposed in C correspond to the most common stereotypical situations in practice. If we consider abbreviations as idioms for expressive and compact presentation of such situations, then their benefits become unconditional and obvious.

So, C emerged as a universal systems programming language. But he did not stay within these limits. By the end of the 80s, the C language, having displaced Fortran from the position of leader, gained massive popularity among programmers around the world and began to be used in a variety of applied problems. A significant role here was played by the spread of Unix (and therefore C) in the university environment, where a new generation of programmers was trained.

Like all languages, C has been gradually improved, but most of the improvements have not been radical. The most significant of these, perhaps, should be considered the introduction of a strict specification of function types, which significantly increased the reliability of inter-module communication in C. All such improvements were enshrined in 1989 in the ANSI standard, which still defines the C language.

But if everything is so rosy, then why do all the other languages ​​continue to be used, which supports their existence? The Achilles heel of the C language was that it turned out to be too low-level for the tasks that were put on the agenda in the 90s. Moreover, this problem has two aspects. On the one hand, too low-level tools were built into the language - primarily memory management and address arithmetic. It is not without reason that changing the bit capacity of processors has a very painful effect on many C programs. On the other hand, C lacks high-level features - abstract data types and objects, polymorphism, exception handling. As a result, in C programs, the technique of implementing a task often dominates its content.

The first attempts to correct these shortcomings began to be made in the early 80s. Even then, Bjarne Stroustrup at AT&T Bell Labs began to develop an extension of the C language under code name. The style of development was quite consistent with the spirit in which the C language itself was created - certain features were introduced into it in order to make work more convenient specific people and groups. The first commercial translator of the new language, called C++, appeared in 1983. It was a preprocessor that translated the program into C code. However, the actual birth of the language can be considered the publication of Stroustrup’s book in 1985. It was from this moment that C++ began to gain worldwide popularity.

The main innovation of C++ is the class mechanism, which makes it possible to define and use new data types. The programmer describes the internal representation of a class object and a set of function-methods for accessing this representation. One of the cherished goals when creating C++ was the desire to increase the percentage of reuse of already written code. The concept of classes offered an inheritance mechanism for this. Inheritance allows you to create new (derived) classes with expanded representation and modified methods without affecting the compiled code of the source (base) classes. At the same time, inheritance provides one of the mechanisms for implementing polymorphism - the basic concept of object-oriented programming, according to which, to perform the same type of processing different types data the same code can be used. Actually, polymorphism is also one of the methods for ensuring code reuse.

The introduction of classes does not exhaust all the innovations of the C++ language. It implements a full-fledged structured exception handling mechanism, the absence of which in C made it much more difficult to write reliable programs, a template mechanism - a sophisticated macro-generation mechanism deeply built into the language, opening another path to code reuse, and much more.

Thus, general line development of the language was aimed at expanding its capabilities by introducing new high-level constructs while maintaining as full compatibility with ANSI C as possible. Of course, the struggle to increase the level of the language also went on on the second front - the same classes allow, with the right approach, to hide low-level operations, so the programmer actually stops working directly with memory and system-dependent entities. However, the language does not contain mechanisms that force the developer to structure the program correctly, and the authors have not issued any systematic recommendations for using its rather sophisticated constructs. They also did not take care in a timely manner to create a standard class library that implements the most frequently encountered data structures.

All this led to the fact that many developers were forced to explore the labyrinths of linguistic semantics themselves and independently find successfully working idioms. For example, at the first stage of language development, many creators of class libraries sought to build a single hierarchy of classes with a common base class Object. This idea was borrowed from Smalltalk, one of the most famous object-oriented languages. However, it turned out to be completely unviable in C++ - carefully designed hierarchies of class libraries turned out to be inflexible, and the work of classes was not obvious. In order for class libraries to be usable, they had to be supplied in source code.

The emergence of template classes completely refuted this direction of development. Inheritance began to be used only in cases where it was necessary to generate a specialized version of an existing class. Libraries began to be composed of separate classes and small unrelated hierarchies. However, along this path it began to decline reuse code, since in C++ polymorphic use of classes from independent hierarchies is impossible. The widespread use of templates leads to an unacceptable increase in the volume of compiled code - let's not forget, templates are implemented using macrogeneration methods.

One of the most serious shortcomings of C++, which it inherited from the C syntax, is the availability of descriptions to the compiler internal structure all used classes. As a consequence, changing the internal structure of the representation of a library class leads to the need to recompile all programs where this library is used. This greatly limits library developers in terms of their modernization, because when releasing new version, they must remain binary compatible with the previous one. It is this problem that makes many experts believe that C++ is unsuitable for running large and very large projects.

And yet, despite the listed shortcomings and even the unavailability of the language standard (this is after fifteen extra years use!), C++ remains one of the most popular programming languages. Its strength lies primarily in its almost complete compatibility with the C language. Thanks to this, C++ programmers have access to all the developments made in C. At the same time, C++, even without the use of classes, brings a number of such important things to C additional features and conveniences that many use it simply as an improved S.

As for the C++ object model, as long as your program does not become very large (hundreds of thousands of lines), it is quite usable. Emerging in Lately The trend towards component-based software only strengthens the position of C++. When developing individual components, the shortcomings of C++ do not yet appear, and the linking of components into a working system is no longer done at the language level, but at the operating system level.

In light of all that has been said, the prospects for C++ do not look bleak. Although he will not have a monopoly on the programming language market. Perhaps the only thing we can say with certainty is that this language will not survive another modernization-expansion. It’s not for nothing that when Java appeared, so much attention was paid to it. close attention. The language, which is close in syntax to C++, and therefore seems familiar to many programmers, has been spared the most glaring shortcomings of C++, inherited from the 70s. However, Java doesn't seem to live up to the role some people have assigned to it.

The special role of the C/C++ languages ​​in modern programming makes it practically meaningless to provide specific addresses on the Internet where you can find materials on them. There are simply too many places like this. However, if you are interested in learning more about the evolution of C++, then start with this short article http://citforum.syzran.ru/programming/prg96/76.shtml.

Alexander Sergeev, [email protected]
Article from BYTE/Russia magazine, March 2000

In order to clearly demonstrate the use of the described languages ​​in practice, we chose a task in which it was required to enter a series of integers from standard input or from a file, and then output only the odd ones, and in reverse order following. This is one of the simplest problems that essentially requires working with arrays, loops, branching and I/O to solve it, and also allows you to demonstrate subroutine calls. At the same time, it is visible and easily perceived.

Listing 1. C

1 #include /* Connect I/O functions */ 2 3 void main(void) 4 ( 5 int M; /* Array of 10 integers, counting from 0 */ 6 int N; 7 for (N=0; N<10; ++N) /* Вводим не более 10 чисел */ 8 if (EOF == scanf ("%d, M+N)) 9 break; /* Если конец файла, прерываем цикл */ 10 11 for (-N; N>=0; --N) /* We go through the array in reverse */ 12 if (M[N]%2) /* order and print odd ones */ 13 printf("%d\n", M[N]); 14 )

  • Line 3. In C/C++, program execution always begins with the main function.
  • Lines 7 and 11. In the loop header, the initial setting, the continuation condition, and the rule for recalculating the loop parameter are indicated, separated by semicolons. Operations ++ And -/- - the most famous abbreviations of the C language, meaning the increment and decrement of a variable, that is, an increase and decrease in its value by one.
  • Line 8. Function scanf enters, according to the format specified by the first parameter, the values ​​of variables whose addresses are specified by the remaining parameters. Here the address where the value is entered is calculated using address arithmetic to the address of the array location M the offset is added by N elements. The same effect can be achieved by writing &M[N].
  • Line 12. Operation % calculates the remainder of a division. Operator condition if is considered executed if the numerical value of the expression is different from zero.
  • Line 13. Function printf- printing by format works in the same way scanf, but instead of addresses it is passed values ​​to be output.
1 #include 2 3 template class Array 4 ( 5 public: Array (T Size=1) : M (new T), N(Size), n(0) () 6 Array (void) ( delete M;) 7 T Count (void) const ( return n; ) 8 T operator (int i) const ( return M[i]; ) 9 void Add (T Data); 11 T* M; // Distributed memory address 12 int N, n; - distributed; n - used 13); 14 15 template void Array ::Add(T Data) 16 ( if (N-n) // If all allocated 17 is used ( int* P = new T; // space, distribute more 18 for (int i=0; i A; // Array of variable size integers 28 while (1) // Infinite loop 29 ( int N; 30 cin >> N; // cin - standard input stream 31 if (cin.eof()) break; // Exit the loop by end of file 32 A.Add(N); // Add the entered number to the array 33 ) 34 for (int N=A.Count()-1; N>=0; --N) // Walk through the array 35 if ( A[N]%2) 36 cout<, and free up memory
  • Lines 3-13. The template class is declared Array with parameter T. It is a variable-sized array of objects of type T. Of course, in our task there is no need to use a template class. However, we wanted to demonstrate how C++ can create a polymorphic data structure that can work with any type of element.
  • Line 5. Class constructor. It initializes the representation of the object. For example, in the field M the address of the memory block ordered by the operation is entered new T.
  • Line 8. Example of operation overloading. Function operator will be called when square brackets appear to the right of a class object Array.
  • Line 9. This function is the main one in the implementation. It adds elements to the array, expanding it as needed. Since it is more complex than the others, its definition is taken from the class description. The functions described in the body of the class are implemented in C++ not by calling, but by inline substitution. This speeds up the program, although it increases its size.
  • Lines 15-24. Definition of a function Array::Add(T)(that's her full name, by the way).
  • Line 27. Create an object of type Array. Template Aggau parameterized by type int.

Why C++

C++ is currently considered the dominant language used for developing commercial software products. In recent years, this dominance has wavered slightly due to similar claims from a programming language like Java, but the pendulum of public opinion has swung the other way, and many programmers who abandoned C++ for Java have recently rushed back to his former affection. In any case, the two languages ​​are so similar that once you learn one, you automatically master 90% of the other.

C# is a new language developed by Microsoft for the networking platform. Essentially, C# is a variation of C++, and despite a number of fundamental differences, the languages ​​C# and C++ are approximately 90% the same. It will probably be a long time before C# competes seriously with C++; but even if this happens, knowledge of the C++ language will be a significant advantage.

C++ is a general purpose programming language. Its natural area of ​​application is system programming, understood in the broad sense of the word. In addition, C++ has been successfully used in many application areas that go far beyond this scope. Implementations of C++ are now available on all machines, from the humblest microcomputers to the largest supercomputers, and on virtually all operating systems.

The emergence and evolution of the C++ language

Bjarne Stroustrup is the developer of the C++ language and the creator of the first translator. He is an employee of the AT&T Bell Laboratories Research Computing Center in Murray Hill (New Jersey, USA). He received a Master's degree in Mathematics and Computer Science from the University of Aarus (Denmark), and a Doctorate in Computer Science from the University of Cambridge (England). He specializes in distributed systems, operating systems, modeling and programming. Along with M. A. Ellis, he is the author of the definitive guide to the C++ language, The Annotated C++ Manual.

Of course, C++ owes a lot to the C language, which remains as a subset of it. All low-level C tools designed to solve the most pressing problems of system programming have also been preserved. C, in turn, owes a lot to its predecessor, the BCPL language. The BCPL language commentary has been restored in C++. Another source of inspiration was the SIMULA-67 language; it was from it that the concept of classes (along with derived classes and virtual functions) was borrowed. C++'s ability to overload operators and the freedom to place declarations wherever an operator may occur are reminiscent of the ALGOL-68 language.

Earlier versions of the language, called "C with classes", were used starting in 1980. This language arose because the author needed to write interrupt-driven simulation programs. The SIMULA-67 language is ideal for this, efficiency aside. The C language with classes was used for large modeling problems. At that time, the possibilities of writing programs on it for which time and memory resources were critical were subjected to strict testing. The language lacked operator overloading, references, virtual functions, and many other features. C++ was first released outside of the author's research group in July 1983, but many of the features of C++ had not yet been developed.

The name C++ (C plus plus) was coined by Rick Mascitti in the summer of 1983. The name reflects the evolutionary nature of the changes in the C language. The notation ++ refers to the operation of growing C. The slightly shorter name C+ is a syntax error. In addition, it has already been used as the name of a completely different language. Experts in C semantics find C++ worse than ++C. The language is not named D because it is an extension of C and does not attempt to solve any problems by eliminating the features of C. Another interesting interpretation of the name C++ can be found in the appendix to .

C++ was originally conceived so that the author and his friends would not have to program in assembly language, C, or other modern high-level languages. Its main purpose is to simplify and make the programming process more enjoyable for the individual programmer. Until recently, there was no plan for C++ development on paper. Design, implementation and documentation proceeded in parallel. There has never been a "C++ Project" or a "C++ Development Committee". Therefore, the language has evolved and continues to evolve in such a way as to overcome all the problems faced by users. The author’s discussions of all problems with his friends and colleagues also serve as impetus for development.

Since the publication of the first edition of this book, the C++ language has undergone significant changes and refinements. This mainly concerns ambiguity resolution in overloading, binding and memory management. However, minor changes have been made to increase compatibility with the C language. Some generalizations and significant extensions have also been introduced, such as multiple inheritance, member functions with static and const specifications, protected members, type templates, and handling special situations. All these extensions and improvements were aimed at making C++ a language in which libraries can be created and used. All changes are described in .

Other extensions introduced between 1985 and 1991 (such as multiple inheritance, static member functions, and pure virtual functions) arose from generalization of C++ programming experience rather than from other languages.

The language extensions made over these six years were primarily aimed at increasing the expressiveness of C++ as a language of data abstraction and object-oriented programming in general, and as a means for creating high-quality libraries with user-defined data types in particular.

Around 1987, it became apparent that C++ standardization work was imminent and that work on it should begin immediately.

AT&T Bell Laboratories was a major contributor to this work. About one hundred representatives from about 20 organizations reviewed and commented on what became the modern version of the reference manual and the source material for ANSI standardization. C++. Finally, at the initiative of Hewlett-Packard, the X3J16 committee was formed within ANSI in December 1989. It is expected that the ANSI (American Standard) C++ standardization work will become an integral part of the ISO (International Organization for Standardization) standardization work.

C++ developed simultaneously with the development of some fundamental classes.

Select the C lessons that interest you:

C is a programming language that was created in 1972 by Dennis M. Ritchie. The standard of the language at that time was demonstrated in the book Ritchie co-authored with Brian Kernighan (The C Programming Language). This standard is called the K&R standard (after Kernighan and Ritchie). Any program written using K&R-C rules will be compiled successfully by any C compiler.

Programmers developing compilers for C began to modernize and develop the language. To avoid confusion, the American National Standards Institute developed the ANSI language standard in 1983. ANSI-C to this day sets the rules for the changes and development of the C language.

C is a compiled programming language. A program consists of instructions and functions that must be translated into binary codes in order to be executed by the computer hardware.
C is quite popular at the present time, this is due to its sought-after qualities such as speed, portability and structuring.

  • Speed

Among all high-level languages, C is a programming language that is closer to assembly language. Thus, many language instructions are addressed directly to the computer hardware, which is why the program runs very quickly. For this reason, C can be used to write operating systems and compilers.

Most developed C compilers generate highly optimized codes, i.e. in other words, small in size (the smaller the code the compiler generates, the more optimized it is).

  • Portability

In principle, it would make sense to write fast running programs in assembly language. But we would have to write them for each platform, since mnemonic assembly codes are adapted for microprocessor families.

C uses standard sets of keywords. Those. the program is written once for any platform, any computer with any operating system. But there are two types of compilers for the language: one for IBM, the other for Apple. But the program text itself is created once and for all.

  • Structuring

Programs written in the C language have their own structure and rules, which encourages the programmer to think logically.
The need to structure the program is only a “plus”, because it is thanks to this that a C program is very easy to design, maintain and debug.

  • Function libraries

C is a programming language that initially contains a small number of operations in its syntax. For example, the language does not have built-in operators for input and output of information, as well as operators for working with strings.

All C capabilities are provided through function libraries, some of which are supplied with the compiler. The library is a separate file attached to the compiler and containing functions for solving specific problems.



Did you like the article? Share with your friends!