Array ( [0] => {{Short description|General-purpose programming language}} [1] => {{Redirect-multi|2|cxx|.cxx|other uses|CXX (disambiguation){{!}}CXX}} [2] => {{Sources|date=March 2024}} [3] => {{pp-move-vandalism|small=yes}} [4] => {{Use dmy dates|date=January 2020}} [5] => {{Infobox programming language [6] => | name = C++ [7] => | logo = ISO C++ Logo.svg [8] => | logo caption = Logo endorsed by the C++ standards committee [9] => | logo size = 120px [10] => | paradigms = [[Multi-paradigm programming language|Multi-paradigm]]: [[procedural programming|procedural]], [[imperative programming|imperative]], [[functional programming|functional]], [[object-oriented programming|object-oriented]], [[generic programming|generic]], [[Modular programming|modular]] [11] => | family = [[C (programming language)|C]] [12] => | designer = [[Bjarne Stroustrup]] [13] => | developer = [[ISO/IEC JTC 1/SC 22|ISO/IEC JTC 1 (Joint Technical Committee 1) / SC 22 (Subcommittee 22)]] / WG 21 (Working Group 21) [14] => | released = {{Start date and age|df=yes|1985}} [15] => | latest release version = [[C++20]] (ISO/IEC 14882:2020) [16] => | latest release date = {{Start date and age|2020|12|15|df=yes}} [17] => | latest preview version = [[C++23]] [18] => | latest preview date = {{Start date and age|2023|03|19|df=yes}} [19] => | typing = [[Static type|Static]], [[strong and weak typing|strong]], [[nominal type system|nominative]], [[type inference|partially inferred]] [20] => | scope = [21] => | platform = [22] => | operating system = [[Cross-platform]] [23] => | file ext = .C, .cc, .cpp, .cxx, {{nowrap|.c++}}, .h, .H, .hh, .hpp, .hxx, {{nowrap|.h++}} .cppm, .ixx,{{cite web|url=https://learn.microsoft.com/en-us/cpp/cpp/modules-cpp?view=msvc-170|title=Overview of modules in C++|date=24 April 2023 |publisher=Microsoft}} [24] => | file format = [25] => | implementations = {{nowraplinks| [[GNU Compiler Collection|GCC]], [[Clang|LLVM Clang]], [[Microsoft Visual C++]], [[C++Builder|Embarcadero C++Builder]], [[Intel C++ Compiler]], [[IBM XL C++]], [[Edison Design Group|EDG]]}} [26] => | dialects = [27] => | wikibooks = C++ Programming [28] => | influenced by = [[Ada (programming language)|Ada]], [[ALGOL 68]],{{cite book |last=Stroustrup |first=Bjarne |date=1996 |pages=699–769 |chapter=A history of C++: 1979-1991 |title=History of programming languages---II |publisher=[[Association for Computing Machinery|ACM]] |doi=10.1145/234286.1057836 |doi-access=free }} [[BCPL]],{{cite web |url=https://www.youtube.com/watch?v=15QF2q66NhU |title=C++20: Reaching for the Aims of C++ - Bjarne Stroustrup - CppCon 2021 |first=Bjarne |last=Stroustrup |publisher=CppCon |date=December 16, 2021 |access-date=30 December 2021 |archive-date=30 December 2021 |archive-url=https://web.archive.org/web/20211230092718/https://www.youtube.com/watch?v=15QF2q66NhU |url-status=live }} [[C (programming language)|C]], [[CLU (programming language)|CLU]], [[F Sharp (programming language)|F#]], {{cite journal | last=Stroustrup | first=Bjarne | title=Thriving in a crowded and changing world: C++ 2006–2020 | journal=Proceedings of the ACM on Programming Languages | publisher=Association for Computing Machinery (ACM) | volume=4 | issue=HOPL | date=2020-06-12 | issn=2475-1421 | doi=10.1145/3386320 | pages=1–168| s2cid=219603741 | doi-access=free }}For the idea of the C++20 stackless coroutines. [[ML (programming language)|ML]], [[Mesa (programming language)|Mesa]], [[Modula-2]], [[Simula]], [[Smalltalk]] [29] => | influenced = [[Ada (programming language)|Ada 95]], [[C Sharp (programming language)|C#]],{{cite journal |last=Naugler |first=David |date=May 2007 |title=C# 2.0 for C++ and Java programmer: conference workshop |journal=Journal of Computing Sciences in Colleges |volume=22 |issue=5 |quote=Although C# has been strongly influenced by Java it has also been strongly influenced by C++ and is best viewed as a descendant of both C++ and Java.}} [[C99]], [[Carbon (programming language)|Carbon]], [[Chapel (programming language)|Chapel]],{{cite web|title=Chapel spec (Acknowledgements)|url=https://chapel-lang.org/spec/spec-0.98.pdf|date=1 October 2015|access-date=14 January 2016|publisher=Cray Inc|archive-date=24 June 2018|archive-url=https://web.archive.org/web/20180624150422/https://chapel-lang.org/spec/spec-0.98.pdf|url-status=live}} [[Clojure]],{{cite web |url=http://www.codequarterly.com/2011/rich-hickey/ |archive-url=https://web.archive.org/web/20170111184835/http://www.codequarterly.com/2011/rich-hickey/ |url-status=dead |archive-date=2017-01-11 |title=Rich Hickey Q&A |first1=Michael |last1=Fogus |website=Code Quarterly |access-date=2017-01-11}} [[D (programming language)|D]], [[Java (programming language)|Java]],{{cite web |url=https://books.google.com/books?id=0rUtBAAAQBAJ&pg=PA133 |title=Cracking The Java Programming Interview :: 2000+ Java Interview Que/Ans |author=Harry. H. Chaudhary |access-date=29 May 2016 |date=28 July 2014 |archive-date=27 May 2021 |archive-url=https://web.archive.org/web/20210527025512/https://books.google.com/books?id=0rUtBAAAQBAJ&pg=PA133 |url-status=live }} [[JS++]],{{cite web|url=https://www.onux.com/jspp/blog/scaling-jspp-abstraction-performance-and-readability/|title=Scaling JS++: Abstraction, Performance, and Readability|author=Roger Poon|date=1 May 2017|access-date=21 April 2020|archive-date=11 May 2020|archive-url=https://web.archive.org/web/20200511095442/https://www.onux.com/jspp/blog/scaling-jspp-abstraction-performance-and-readability/|url-status=live}} [[Lua (programming language)|Lua]],{{Cite web|url=https://www.lua.org/history.html|title=The evolution of an extension language: a history of Lua|website=www.lua.org|access-date=2023-01-04}} [[Nim (programming language)|Nim]],{{cite web|url=https://nim-lang.org/faq.html|title=FAQ Nim Programming Language|access-date=2020-04-21|archive-date=11 July 2017|archive-url=https://web.archive.org/web/20170711004631/https://nim-lang.org/faq.html|url-status=live}} [[Objective-C++]], [[Perl]], [[PHP]], [[Python (programming language)|Python]],{{Cite web|url=https://docs.python.org/tutorial/classes.html|title=9. Classes — Python 3.6.4 documentation|website=docs.python.org|access-date=2018-01-09|archive-date=23 October 2012|archive-url=https://web.archive.org/web/20121023030209/http://docs.python.org/tutorial/classes.html|url-status=live}} [[Rust (programming language)|Rust]],{{Cite web|url=https://doc.rust-lang.org/reference/influences.html|title=Influences - The Rust Reference|website=doc.rust-lang.org|access-date=2023-01-04}} [[Seed7]] [30] => }} [31] => [32] => '''C++''' ({{IPAc-en|'|s|i:|_|p|l|V|s|_|p|l|V|s}}, pronounced "'''C plus plus'''" and sometimes abbreviated as '''CPP''') is a [[High-level programming language|high-level]], [[general-purpose programming language]] created by Danish computer scientist [[Bjarne Stroustrup]]. First released in 1985 as an extension of the [[C (programming language)|C programming language]], it has since expanded significantly over time; {{as of|1997|lc=true}}, C++ has [[object-oriented programming|object-oriented]], [[generic programming|generic]], and [[functional programming|functional]] features, in addition to facilities for [[Low-level programming language|low-level]] [[Memory (computing)|memory]] manipulation for making things like [[Microcomputer|microcomputers]] or to make operating systems like [[Linux]] or [[Microsoft Windows|Windows]]. It is almost always implemented as a [[compiled language]], and many vendors provide [[List of compilers#C.2B.2B compilers|C++ compilers]], including the [[Free Software Foundation]], [[LLVM]], [[Microsoft]], [[Intel]], [[Embarcadero_Technologies|Embarcadero]], [[Oracle Developer Studio|Oracle]], and [[IBM]].{{Cite book |last=Stroustrup |first=Bjarne |author-link=Bjarne Stroustrup |title=The C++ Programming Language |year=1997 |edition=Third |chapter=1 |publisher=Addison-Wesley |isbn=0-201-88954-4 |oclc=59193992 |url=https://archive.org/details/cprogramminglang00stro_0 }} [33] => [34] => C++ was designed with [[systems programming]] and [[embedded software|embedded]], resource-constrained software and large systems in mind, with [[performance (software)|performance]], efficiency, and flexibility of use as its design highlights.{{cite web|url=https://www.youtube.com/watch?v=86xWVb4XIyE|author=Stroustrup, B.|title=Lecture:The essence of C++. University of Edinburgh.|website=[[YouTube]]|date=6 May 2014|access-date=12 June 2015|archive-date=28 April 2015|archive-url=https://web.archive.org/web/20150428003608/https://www.youtube.com/watch?v=86xWVb4XIyE|url-status=live}} C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including [[application software|desktop applications]], [[video game development|video games]], [[Server (computing)|servers]] (e.g., [[e-commerce]], [[Web search engine|web search]], or [[database]]s), and performance-critical applications (e.g., [[telephone switches]] or [[space probes]]).{{cite web |url=http://www.stroustrup.com/applications.html |title=C++ Applications |date=17 February 2014 |access-date=5 May 2014 |first=Bjarne |last=Stroustrup |website=stroustrup.com |archive-date=4 April 2021 |archive-url=https://web.archive.org/web/20210404065717/https://www.stroustrup.com/applications.html |url-status=live }} [35] => [36] => C++ is standardized by the [[International Organization for Standardization]] (ISO), with the latest standard version ratified and published by ISO in December 2020 as ''ISO/IEC 14882:2020'' (informally known as [[C++20]]). The C++ programming language was initially standardized in 1998 as ''ISO/IEC 14882:1998'', which was then amended by the [[C++03]], [[C++11]], [[C++14]], and [[C++17]] standards. The current {{nowrap|[[C++20]]}} standard supersedes these with new features and an enlarged [[C++ Standard library|standard library]]. Before the initial standardization in 1998, C++ was developed by Stroustrup at [[Bell Labs]] since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided [[High-level programming language|high-level features]] for program organization.{{cite web |title=Bjarne Stroustrup's Homepage |url=http://www.stroustrup.com |website=www.stroustrup.com |access-date=15 May 2013 |archive-date=14 May 2019 |archive-url=https://web.archive.org/web/20190514123147/http://www.stroustrup.com/ |url-status=live }} Since 2012, C++ has been on a three-year release schedule{{Cite web|url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1000r4.pdf|title=C++ IS schedule|access-date=9 August 2020|archive-date=10 August 2020|archive-url=https://web.archive.org/web/20200810105609/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1000r4.pdf|url-status=live}} with [[C++23]] as the next planned standard.{{cite web |title = C++; Where it's heading |url = https://dzone.com/articles/c-where-is-it-heading-and-what-are-the-new-feature |access-date = 3 December 2018 |archive-date = 3 December 2018 |archive-url = https://web.archive.org/web/20181203104022/https://dzone.com/articles/c-where-is-it-heading-and-what-are-the-new-feature |url-status = live }} [37] => [38] => ==History== [39] => [[File:BjarneStroustrup.jpg|thumb|Bjarne Stroustrup, the creator of C++, in his AT&T New Jersey office, {{circa}} 2000]] [40] => [41] => In 1979, [[Bjarne Stroustrup]], a Danish [[computer scientist]], began work on "{{visible anchor|C with [[Class (computer programming)|Classes]]}}", the predecessor to C++.{{cite web|url = http://www.stroustrup.com/bs_faq.html#invention|title = Bjarne Stroustrup's FAQ: When was C++ invented?|first = Bjarne|last = Stroustrup|website = stroustrup.com|date = 7 March 2010|access-date = 16 September 2010|archive-date = 6 February 2016|archive-url = https://web.archive.org/web/20160206214150/http://www.stroustrup.com/bs_faq.html#invention|url-status = live}} The motivation for creating a new language originated from Stroustrup's experience in programming for his PhD thesis. Stroustrup found that [[Simula]] had features that were very helpful for large software development, but the language was too slow for practical use, while [[BCPL]] was fast but too low-level to be suitable for large software development. When Stroustrup started working in [[AT&T Bell Labs]], he had the problem of analyzing the [[Unix|UNIX]] [[Kernel (operating system)|kernel]] with respect to [[distributed computing]]. Remembering his PhD experience, Stroustrup set out to enhance the [[C (programming language)|C]] language with [[Simula]]-like features.{{cite web|url = http://stroustrup.com/hopl-almost-final.pdf|title = Evolving a language in and for the real world: C++ 1991-2006|first = Bjarne|last = Stroustrup|access-date = 14 August 2013|archive-date = 20 November 2007|archive-url = https://web.archive.org/web/20071120015600/http://www.research.att.com/~bs/hopl-almost-final.pdf|url-status = live}} C was chosen because it was general-purpose, fast, portable, and widely used. In addition to C and Simula's influences, other languages influenced this new language, including [[ALGOL 68]], [[Ada (programming language)|Ada]], [[CLU (programming language)|CLU]], and [[ML (programming language)|ML]].{{Citation needed|date=February 2024}} [42] => [43] => Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including [[class (computer programming)|classes]], [[derived class]]es, [[strong and weak typing|strong typing]], [[inlining]], and [[default argument]]s.{{cite web|last1=Stroustrup|first1=Bjarne|title=A History of C ++ : 1979− 1991|url=http://www.stroustrup.com/hopl2.pdf|access-date=18 July 2013|archive-date=2 February 2019|archive-url=https://web.archive.org/web/20190202050609/http://www.stroustrup.com/hopl2.pdf|url-status=live}} [44] => [45] => [[File:20160121 CppFRUG Joel Falcou CppQuiz 3.jpg|thumb|left|A quiz on C++11 features being given in Paris in 2015]] [46] => In 1982, Stroustrup started to develop a successor to C with Classes, which he named "C++" (++ being the [[increment operator]] in C) after going through several other names. New features were added, including [[virtual function]]s, function name and [[operator overloading]], [[reference (C++)|reference]]s, constants, type-safe free-store memory allocation (new/delete), improved type checking, and BCPL-style single-line comments with two forward slashes (//). Furthermore, Stroustrup developed a new, standalone compiler for C++, [[Cfront]]. [47] => [48] => In 1984, Stroustrup implemented the first stream input/output library. The idea of providing an output operator rather than a named output function was suggested by [[Douglas McIlroy|Doug McIlroy]] (who had previously suggested [[Pipeline (Unix)|Unix pipes]]). [49] => [50] => In 1985, the first edition of ''[[The C++ Programming Language]]'' was released, which became the definitive reference for the language, as there was not yet an official standard.{{cite web|url = http://www.stroustrup.com/1st.html|title = The C++ Programming Language|edition = First|first = Bjarne|last = Stroustrup|access-date = 16 September 2010|archive-date = 9 August 2012|archive-url = https://web.archive.org/web/20120809032136/http://www.stroustrup.com/1st.html|url-status = live}} The first commercial implementation of C++ was released in October of the same year. [51] => [52] => In 1989, C++ 2.0 was released, followed by the updated second edition of ''The C++ Programming Language'' in 1991.{{cite web|url = http://www.stroustrup.com/2nd.html|title = The C++ Programming Language|edition = Second|first = Bjarne|last = Stroustrup|access-date = 16 September 2010|archive-date = 9 August 2012|archive-url = https://web.archive.org/web/20120809032141/http://www.stroustrup.com/2nd.html|url-status = live}} New features in 2.0 included multiple inheritance, abstract classes, static member functions, [[const correctness|const member functions]], and protected members. In 1990, ''The Annotated C++ Reference Manual'' was published. This work became the basis for the future standard. Later feature additions included [[template (programming)|template]]s, [[exception handling|exceptions]], [[namespaces]], new [[cast (computer science)|cast]]s, and a [[Boolean datatype|Boolean type]]. [53] => [54] => In 1998, C++98 was released, standardizing the language, and a minor update ([[C++03]]) was released in 2003. [55] => [56] => After C++98, C++ evolved relatively slowly until, in 2011, the [[C++11]] standard was released, adding numerous new features, enlarging the standard library further, and providing more facilities to C++ programmers. After a minor {{nowrap|[[C++14]]}} update released in December 2014, various new additions were introduced in [[C++17]].{{cite web |url=https://herbsutter.com/2016/06/30/trip-report-summer-iso-c-standards-meeting-oulu/ |title=Trip report: Summer ISO C++ standards meeting (Oulu) |last=Sutter |first=Herb |website=herbsutter.com |date=30 June 2016 |archive-url=https://web.archive.org/web/20161008031743/https://herbsutter.com/2016/06/30/trip-report-summer-iso-c-standards-meeting-oulu/ |archive-date=8 October 2016 |quote=the next standard after C++17 will be C++20}} After becoming finalized in February 2020,{{cite web|url=http://open-std.org/JTC1/SC22/WG21/docs/papers/2019/n4817.pdf|title=N4817: 2020 Prague Meeting Invitation and Information|last=Dusíková|first=Hana|date=2019-11-06|access-date=2020-02-13|archive-date=29 December 2019|archive-url=https://web.archive.org/web/20191229102449/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4817.pdf|url-status=live}} a draft of the C++20 standard was approved on 4 September 2020, and officially published on 15 December 2020.{{cite web |title=Current Status |url=https://isocpp.org/std/status |website=isocpp.org |access-date=7 September 2020 |archive-date=8 September 2020 |archive-url=https://web.archive.org/web/20200908083135/https://isocpp.org/std/status |url-status=live }}{{cite web |title=C++20 Approved -- Herb Sutter |url=https://isocpp.org/blog/2020/09/cpp20-approved-herb-sutter |website=isocpp.org |access-date=8 September 2020 |archive-date=11 September 2020 |archive-url=https://web.archive.org/web/20200911150359/https://isocpp.org/blog/2020/09/cpp20-approved-herb-sutter |url-status=live }} [57] => [58] => On January 3, 2018, Stroustrup was announced as the 2018 winner of the [[Charles Stark Draper Prize]] for Engineering, "for conceptualizing and developing the C++ programming language".{{cite press release |url=https://www.nae.edu/177355.aspx |title=Computer Science Pioneer Bjarne Stroustrup to Receive the 2018 Charles Stark Draper Prize for Engineering |publisher=National Academy of Engineering |date=3 January 2018 |access-date=14 December 2021 |archive-url=https://web.archive.org/web/20180103190112/https://www.nae.edu/177355.aspx |archive-date=3 January 2018}} [59] => [60] => {{As of|2022|December}}, C++ ranked third on the [[TIOBE index]], surpassing [[Java (programming language)|Java]] for the first time in the history of the index. It ranks third, after [[Python (programming language)|Python]] and [[C (programming language)|C]].{{cite web|url=https://www.tiobe.com/tiobe-index/|title=TIOBE Index for January 2021|author=TIOBE|date=January 2022|website=TIOBE.com|publisher=TIOBE Company|access-date=2022-02-02|archive-date=25 February 2018|archive-url=https://web.archive.org/web/20180225101948/https://www.tiobe.com/tiobe-index/|url-status=live}} [61] => [62] => ===Etymology=== [63] => According to Stroustrup, "the name signifies the evolutionary nature of the changes from C."{{cite web |url=http://www.stroustrup.com/bs_faq.html#name |title=Bjarne Stroustrup's FAQ – Where did the name "C++" come from? |access-date=16 January 2008 |archive-date=6 February 2016 |archive-url=https://web.archive.org/web/20160206214150/http://www.stroustrup.com/bs_faq.html#name |url-status=live }} This name is credited to Rick Mascitti (mid-1983) and was first used in December 1983. When Mascitti was questioned informally in 1992 about the naming, he indicated that it was given in a [[tongue-in-cheek]] spirit. The name comes from C's ++ [[operator (programming)|operator]] (which [[increment and decrement operators|increments]] the [[value (computer science)|value]] of a [[variable (programming)|variable]]) and a common [[naming convention]] of using "+" to indicate an enhanced computer program. [64] => [65] => During C++'s development period, the language had been referred to as "new C" and "C with Classes"{{cite web|title=C For C++ Programmers|url=https://www.ccs.neu.edu/course/com3620/parent/C-for-Java-C++/c-for-c++-alt.html|publisher=[[Northeastern University]]|access-date=7 September 2015|archive-url=https://web.archive.org/web/20101117003419/http://www.ccs.neu.edu/course/com3620/parent/C-for-Java-C++/c-for-c++-alt.html|archive-date=17 November 2010|url-status=dead|df=dmy-all}} before acquiring its final name. [66] => [67] => ===Philosophy=== [68] => Throughout C++'s life, its development and evolution has been guided by a set of principles: [69] => [70] => * It must be driven by actual problems and its features should be immediately useful in real world programs. [71] => * Every feature should be implementable (with a reasonably obvious way to do so). [72] => * Programmers should be free to pick their own programming style, and that style should be fully supported by C++. [73] => * Allowing a useful feature is more important than preventing every possible misuse of C++. [74] => * It should provide facilities for organising programs into separate, well-defined parts, and provide facilities for combining separately developed parts. [75] => * No implicit violations of the [[type system]] (but allow explicit violations; that is, those explicitly requested by the programmer). [76] => * User-created types need to have the same support and performance as built-in types. [77] => * Unused features should not negatively impact created executables (e.g. in lower performance). [78] => * There should be no language beneath C++ (except [[assembly language]]). [79] => * C++ should work alongside other existing [[programming language]]s, rather than fostering its own separate and incompatible [[programming environment]]. [80] => * If the programmer's intent is unknown, allow the programmer to specify it by providing manual control. [81] => [82] => ===Standardization=== [83] => {{main|C++03|C++11|C++14|C++17|C++20|C++23}} [84] => {| class="wikitable floatright" style="margin-left: 1.5em;" [85] => |+C++ standards [86] => |- [87] => !scope="col"| Year [88] => !scope="col"| ISO/IEC Standard [89] => !scope="col"| Informal name [90] => |- [91] => !scope="row"| 1998 [92] => | | 14882:1998{{cite web|title=ISO/IEC 14882:1998|publisher=International Organization for Standardization|url=https://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=25845|access-date=23 November 2018|archive-date=15 January 2017|archive-url=https://web.archive.org/web/20170115080045/http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=25845|url-status=live}} || C++98 [93] => |- [94] => !scope="row"| 2003 [95] => | | 14882:2003{{cite web|title=ISO/IEC 14882:2003|publisher=International Organization for Standardization|url=https://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=38110|access-date=23 November 2018|archive-date=13 August 2021|archive-url=https://web.archive.org/web/20210813193332/https://www.iso.org/standard/38110.html|url-status=live}} || [[C++03]] [96] => |- [97] => !scope="row"| 2011 [98] => | | 14882:2011{{cite web|title=ISO/IEC 14882:2011|publisher=International Organization for Standardization|url=https://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=50372|access-date=23 November 2018|archive-date=27 May 2016|archive-url=https://web.archive.org/web/20160527084921/http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=50372|url-status=live}} || [[C++11]], C++0x [99] => |- [100] => !scope="row"| 2014 [101] => | | 14882:2014{{cite web|title=ISO/IEC 14882:2014|publisher=International Organization for Standardization|url=https://www.iso.org/iso/home/store/catalogue_ics/catalogue_detail_ics.htm?csnumber=64029&ICS1=35&ICS2=60|access-date=23 November 2018|archive-date=29 April 2016|archive-url=https://web.archive.org/web/20160429201210/http://www.iso.org/iso/home/store/catalogue_ics/catalogue_detail_ics.htm?csnumber=64029&ICS1=35&ICS2=60|url-status=live}} || [[C++14]], C++1y [102] => |- [103] => !scope="row"| 2017 [104] => | | 14882:2017{{cite web|title=ISO/IEC 14882:2017|publisher=International Organization for Standardization|url=https://www.iso.org/standard/68564.html|access-date=2 December 2017|archive-date=29 January 2013|archive-url=https://web.archive.org/web/20130129110331/http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372|url-status=live}} || [[C++17]], C++1z [105] => |- [106] => !scope="row"| 2020 [107] => | | 14882:2020{{cite web|title=ISO/IEC 14882:2020|publisher=International Organization for Standardization|url=https://www.iso.org/standard/79358.html|access-date=16 December 2020|archive-date=16 December 2020|archive-url=https://web.archive.org/web/20201216154357/https://www.iso.org/standard/79358.html|url-status=live}} || [[C++20]], C++2a [108] => |- [109] => !scope="row"| 2023 [110] => | | || [[C++23]] [111] => |} [112] => [113] => C++ is standardized by an [[International Organization for Standardization|ISO]] working group known as [[ISO/IEC JTC 1/SC 22|JTC1/SC22/WG21]]. So far, it has published six revisions of the C++ standard and is currently working on the next revision, [[C++23]]. [114] => [115] => [[File:C++ Standards Committee meeting - July 1996 Stockholm - Wednesday general session.jpg|thumb|right|Scene during the C++ standards committee meeting in Stockholm in 1996]] [116] => In 1998, the ISO working group standardized C++ for the first time as ''ISO/IEC 14882:1998'', which is informally known as ''C++98''. In 2003, it published a new version of the C++ standard called ''ISO/IEC 14882:2003'', which fixed problems identified in C++98. [117] => [118] => The next major revision of the standard was informally referred to as "C++0x", but it was not released until 2011.{{cite web|url=https://herbsutter.com/2011/08/12/we-have-an-international-standard-c0x-is-unanimously-approved/|title=We have an international standard: C++0x is unanimously approved|website=Sutter's Mill|date=12 August 2011|access-date=23 November 2018|archive-date=28 June 2018|archive-url=https://web.archive.org/web/20180628182816/https://herbsutter.com/2011/08/12/we-have-an-international-standard-c0x-is-unanimously-approved/|url-status=live}} [[C++11]] (14882:2011) included many additions to both the core language and the standard library. [119] => [120] => In 2014, [[C++14]] (also known as C++1y) was released as a small extension to C++11, featuring mainly bug fixes and small improvements.{{Cite web|url=https://channel9.msdn.com/Events/Build/2012/2-005|title=The Future of C++|via=channel9.msdn.com|access-date=23 November 2018|archive-date=23 October 2018|archive-url=https://web.archive.org/web/20181023213741/https://channel9.msdn.com/Events/Build/2012/2-005|url-status=live}} The Draft International Standard ballot procedures completed in mid-August 2014.{{Cite web|url=https://isocpp.org/blog/2014/08/we-have-cpp14|title=We have C++14! : Standard C++|website=isocpp.org|access-date=19 August 2014|archive-date=19 August 2014|archive-url=https://web.archive.org/web/20140819083101/https://isocpp.org/blog/2014/08/we-have-cpp14|url-status=live}} [121] => [122] => After C++14, a major revision [[C++17]], informally known as C++1z, was completed by the ISO C++ committee in mid July 2017 and was approved and published in December 2017.{{Cite web|url=https://herbsutter.com/2017/07/15/trip-report-summer-iso-c-standards-meeting-toronto/|title=Trip report: Summer ISO C++ standards meeting (Toronto)|first=Herb|last=Sutter|date=15 July 2017|access-date=4 August 2017|archive-date=6 August 2017|archive-url=https://web.archive.org/web/20170806182136/https://herbsutter.com/2017/07/15/trip-report-summer-iso-c-standards-meeting-toronto/|url-status=live}} [123] => [124] => As part of the standardization process, ISO also publishes [[International Organization for Standardization#International standards and other publications|technical reports and specifications]]: [125] => [126] => * ISO/IEC TR 18015:2006{{cite web|publisher=International Organization for Standardization|title=ISO/IEC TR 18015:2006|url=https://www.iso.org/standard/43351.html|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115203236/https://www.iso.org/standard/43351.html|url-status=live}} on the use of C++ in embedded systems and on performance implications of C++ language and library features, [127] => * ISO/IEC TR 19768:2007{{cite web|url=https://www.iso.org/standard/43289.html|title=ISO/IEC TR 19768:2007|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=4 March 2016|archive-url=https://web.archive.org/web/20160304045148/http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=43289|url-status=live}} (also known as the [[C++ Technical Report 1]]) on library extensions mostly integrated into [[C++11]], [128] => * ISO/IEC TR 29124:2010{{cite web|url=https://www.iso.org/standard/50511.html|title=ISO/IEC TR 29124:2010|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=12 January 2019|archive-url=https://web.archive.org/web/20190112054620/https://www.iso.org/standard/50511.html|url-status=live}} on special mathematical functions, integrated into {{nowrap|[[C++17]]}}, [129] => * ISO/IEC TR 24733:2011{{cite web|url=https://www.iso.org/standard/38843.html|title=ISO/IEC TR 24733:2011|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115203556/https://www.iso.org/standard/38843.html|url-status=live}} on [[decimal floating point|decimal floating-point]] arithmetic, [130] => * ISO/IEC TS 18822:2015{{cite web|url=https://www.iso.org/standard/63483.html|title=ISO/IEC TS 18822:2015|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201441/https://www.iso.org/standard/63483.html|url-status=live}} on the standard filesystem library, integrated into [[C++17]], [131] => * ISO/IEC TS 19570:2015{{cite web|url=https://www.iso.org/standard/65241.html|title=ISO/IEC TS 19570:2015|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201509/https://www.iso.org/standard/65241.html|url-status=live}} on [[parallel computing|parallel]] versions of the standard library algorithms, integrated into [[C++17]], [132] => * ISO/IEC TS 19841:2015{{cite web|url=https://www.iso.org/standard/66343.html|title=ISO/IEC TS 19841:2015|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201300/https://www.iso.org/standard/66343.html|url-status=live}} on software [[transactional memory]], [133] => * ISO/IEC TS 19568:2015{{cite web|url=https://www.iso.org/standard/65238.html|title=ISO/IEC TS 19568:2015|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115202436/https://www.iso.org/standard/65238.html|url-status=live}} on a new set of library extensions, some of which are already integrated into [[C++17]], [134] => * ISO/IEC TS 19217:2015{{cite web|url=https://www.iso.org/standard/64031.html|title=ISO/IEC TS 19217:2015|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201732/https://www.iso.org/standard/64031.html|url-status=live}} on the C++ [[concepts (C++)|concepts]], integrated into [[C++20]], [135] => * ISO/IEC TS 19571:2016{{cite web|url=https://www.iso.org/standard/65242.html|title=ISO/IEC TS 19571:2016|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201226/https://www.iso.org/standard/65242.html|url-status=live}} on the library extensions for concurrency, some of which are already integrated into [[C++20]], [136] => * ISO/IEC TS 19568:2017{{cite web|url=https://www.iso.org/standard/70587.html|title=ISO/IEC TS 19568:2017|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115202428/https://www.iso.org/standard/70587.html|url-status=live}} on a new set of general-purpose library extensions, [137] => * ISO/IEC TS 21425:2017{{cite web|url=https://www.iso.org/standard/70910.html|title=ISO/IEC TS 21425:2017|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201957/https://www.iso.org/standard/70910.html|url-status=live}} on the library extensions for ranges, integrated into [[C++20]], [138] => * ISO/IEC TS 22277:2017{{cite web|url=https://www.iso.org/standard/73008.html|title=ISO/IEC TS 22277:2017|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115202004/https://www.iso.org/standard/73008.html|url-status=live}} on coroutines, integrated into [[C++20]], [139] => * ISO/IEC TS 19216:2018{{cite web|url=https://www.iso.org/standard/64030.html|title=ISO/IEC TS 19216:2018|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201923/https://www.iso.org/standard/64030.html|url-status=live}} on the networking library, [140] => * ISO/IEC TS 21544:2018{{cite web|url=https://www.iso.org/standard/71051.html|title=ISO/IEC TS 21544:2018|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201858/https://www.iso.org/standard/71051.html|url-status=live}} on modules, integrated into [[C++20]], [141] => * ISO/IEC TS 19570:2018{{cite web|url=https://www.iso.org/standard/70588.html|title=ISO/IEC TS 19570:2018|publisher=International Organization for Standardization|access-date=15 February 2019|archive-date=15 January 2019|archive-url=https://web.archive.org/web/20190115201519/https://www.iso.org/standard/70588.html|url-status=live}} on a new set of library extensions for parallelism, and [142] => * ISO/IEC TS 23619:2021{{cite web|url=https://www.iso.org/standard/76425.html|title=ISO/IEC TS 23619:2021|publisher=International Organization for Standardization|access-date=11 October 2021|url-status=live|archive-url=https://web.archive.org/web/20181215153205/https://www.iso.org/standard/76425.html |archive-date=15 December 2018 }} on new extensions for reflection. [143] => More technical specifications are in development and pending approval, including new set of concurrency extensions. [144] => [145] => ==Language== [146] => The C++ language has two main components: a direct mapping of hardware features provided primarily by the C subset, and zero-overhead abstractions based on those mappings. Stroustrup describes C++ as "a light-weight abstraction programming language [designed] for building and using efficient and elegant abstractions"; and "offering both hardware access and abstraction is the basis of C++. Doing it efficiently is what distinguishes it from other languages."{{cite web|url=https://www.infoq.com/news/2015/04/stroustrup-cpp17-interview|author=B. Stroustrup (interviewed by Sergio De Simone)|date=30 April 2015|access-date=8 July 2015|title=Stroustrup: Thoughts on C++17 - An Interview|archive-date=8 July 2015|archive-url=https://web.archive.org/web/20150708132155/http://www.infoq.com/news/2015/04/stroustrup-cpp17-interview|url-status=live}} [147] => [148] => C++ inherits most of [[C syntax|C's syntax]]. The following is Bjarne Stroustrup's version of the [[Hello world program]] that uses the [[C++ Standard Library]] stream facility to write a message to [[Standard output#Standard output (stdout)|standard output]]:{{Cite book |first=Bjarne |last=Stroustrup |year=2000 |page=46 |title=The C++ Programming Language |edition=Special |publisher=Addison-Wesley |isbn=0-201-70073-5 }}{{cite web |url=http://www.stroustrup.com/3rd_issues.html |title=Open issues for The C++ Programming Language (3rd Edition) |first=Bjarne |last=Stroustrup |access-date=5 May 2014 |archive-date=5 May 2014 |archive-url=https://web.archive.org/web/20140505221112/http://www.stroustrup.com/3rd_issues.html |url-status=live }}This code is copied directly from Bjarne Stroustrup's errata page (p. 633). He addresses the use of '\n' rather than std::endl. Also see [http://www.stroustrup.com/bs_faq2.html#void-main Can I write "void main()"?] {{Webarchive|url=https://web.archive.org/web/20200702224848/http://www.stroustrup.com/bs_faq2.html#void-main |date=2 July 2020 }} for an explanation of the implicit return 0; in the main function. This implicit return is ''not'' available in other functions. [149] => [150] => [172] => #include [173] => [174] => int main() [175] => { [176] => std::cout << "Hello, world!\n"; [177] => } [178] => [195] => [196] => ===Object storage=== [197] => As in C, C++ supports four types of [[memory management]]: static storage duration objects, thread storage duration objects, automatic storage duration objects, and dynamic storage duration objects.[[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]]. ''[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf Programming Languages – C++11 Draft (n3797)] {{Webarchive|url=https://web.archive.org/web/20181002093659/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf |date=2 October 2018 }} §3.7 Storage duration [basic.stc]'' [198] => [199] => ====Static storage duration objects==== [200] => Static storage duration objects are created before main() is entered (see exceptions below) and destroyed in reverse order of creation after main() exits. The exact order of creation is not specified by the standard (though there are some rules defined below) to allow implementations some freedom in how to organize their implementation. More formally, objects of this type have a lifespan that "shall last for the duration of the program".[[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]]. ''[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf Programming Languages – C++11 Draft (n3797)] {{Webarchive|url=https://web.archive.org/web/20181002093659/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf |date=2 October 2018 }} §3.7.1 Static Storage duration [basic.stc.static]'' [201] => [202] => Static storage duration objects are initialized in two phases. First, "static initialization" is performed, and only ''after'' all static initialization is performed, "dynamic initialization" is performed. In static initialization, all objects are first initialized with zeros; after that, all objects that have a constant initialization phase are initialized with the constant expression (i.e. variables initialized with a literal or constexpr). Though it is not specified in the standard, the static initialization phase can be completed at compile time and saved in the data partition of the executable. Dynamic initialization involves all object initialization done via a constructor or function call (unless the function is marked with constexpr, in C++11). The dynamic initialization order is defined as the order of declaration within the compilation unit (i.e. the same file). No guarantees are provided about the order of initialization between compilation units. [203] => [204] => ====Thread storage duration objects==== [205] => Variables of this type are very similar to static storage duration objects. The main difference is the creation time is just prior to thread creation and destruction is done after the thread has been joined.[[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]]. ''[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf Programming Languages – C++11 Draft (n3797)] {{Webarchive|url=https://web.archive.org/web/20181002093659/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf |date=2 October 2018 }} §3.7.2 Thread Storage duration [basic.stc.thread]'' [206] => [207] => ====Automatic storage duration objects==== [208] => The most common variable types in C++ are local variables inside a function or block, and temporary variables.[[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]]. ''[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf Programming Languages – C++11 Draft (n3797)] {{Webarchive|url=https://web.archive.org/web/20181002093659/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf |date=2 October 2018 }} §3.7.3 Automatic Storage duration [basic.stc.auto]'' The common feature about automatic variables is that they have a lifetime that is limited to the scope of the variable. They are created and potentially initialized at the point of declaration (see below for details) and destroyed in the ''reverse'' order of creation when the scope is left. This is implemented by allocation on the [[Stack-based memory allocation|stack]]. [209] => [210] => Local variables are created as the point of execution passes the declaration point. If the variable has a constructor or initializer this is used to define the initial state of the object. Local variables are destroyed when the local block or function that they are declared in is closed. C++ destructors for local variables are called at the end of the object lifetime, allowing a discipline for automatic resource management termed [[Resource Acquisition Is Initialization|RAII]], which is widely used in C++. [211] => [212] => Member variables are created when the parent object is created. Array members are initialized from 0 to the last member of the array in order. Member variables are destroyed when the parent object is destroyed in the reverse order of creation. i.e. If the parent is an "automatic object" then it will be destroyed when it goes out of scope which triggers the destruction of all its members. [213] => [214] => Temporary variables are created as the result of expression evaluation and are destroyed when the statement containing the expression has been fully evaluated (usually at the ; at the end of a statement). [215] => [216] => ====Dynamic storage duration objects==== [217] => {{Main|new and delete (C++)}} [218] => [219] => These objects have a dynamic lifespan and can be created directly with a call to {{cpp|new}} and destroyed explicitly with a call to {{cpp|delete}}.[[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]]. ''[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf Programming Languages – C++11 Draft (n3797)] {{Webarchive|url=https://web.archive.org/web/20181002093659/http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf |date=2 October 2018 }} §3.7.4 Dynamic Storage duration [basic.stc.dynamic]'' C++ also supports malloc and free, from C, but these are not compatible with {{cpp|new}} and {{cpp|delete}}. Use of {{cpp|new}} returns an address to the allocated memory. The C++ Core Guidelines advise against using {{cpp|new}} directly for creating dynamic objects in favor of smart pointers through {{cpp|make_unique}} for single ownership and {{cpp|make_shared}} for reference-counted multiple ownership,{{Cite web|url=https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly|title=C++ Core Guidelines|website=isocpp.github.io|access-date=2020-02-09|archive-date=8 February 2020|archive-url=https://web.archive.org/web/20200208160101/http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly|url-status=live}} which were introduced in C++11. [220] => [221] => ===Templates=== [222] => {{See also|Template metaprogramming|Generic programming}} [223] => [[C++ templates]] enable [[generic programming]]. {{nowrap|C++}} supports function, class, alias, and variable templates. Templates may be parameterized by types, compile-time constants, and other templates. Templates are implemented by ''instantiation'' at compile-time. To instantiate a template, compilers substitute specific arguments for a template's parameters to generate a concrete function or class instance. Some substitutions are not possible; these are eliminated by an overload resolution policy described by the phrase "[[Substitution failure is not an error]]" (SFINAE). Templates are a powerful tool that can be used for [[generic programming]], [[template metaprogramming]], and code optimization, but this power implies a cost. Template use may increase [[object code]] size, because each template instantiation produces a copy of the template code: one for each set of template arguments, however, this is the same or smaller amount of code that would be generated if the code were written by hand. This is in contrast to run-time generics seen in other languages (e.g., [[Generics in Java|Java]]) where at compile-time the type is erased and a single template body is preserved. [224] => [225] => Templates are different from [[Macro (computer science)|macro]]s: while both of these compile-time language features enable conditional compilation, templates are not restricted to lexical substitution. Templates are aware of the semantics and type system of their companion language, as well as all compile-time type definitions, and can perform high-level operations including programmatic flow control based on evaluation of strictly type-checked parameters. Macros are capable of conditional control over compilation based on predetermined criteria, but cannot instantiate new types, recurse, or perform type evaluation and in effect are limited to pre-compilation text-substitution and text-inclusion/exclusion. In other words, macros can control compilation flow based on pre-defined symbols but cannot, unlike templates, independently instantiate new symbols. Templates are a tool for static [[Polymorphism in object-oriented programming|polymorphism]] (see below) and [[generic programming]]. [226] => [227] => In addition, templates are a compile-time mechanism in C++ that is [[Turing-complete]], meaning that any computation expressible by a computer program can be computed, in some form, by a [[template metaprogramming|template metaprogram]] prior to runtime. [228] => [229] => In summary, a template is a compile-time parameterized function or class written without knowledge of the specific arguments used to instantiate it. After instantiation, the resulting code is equivalent to code written specifically for the passed arguments. In this manner, templates provide a way to decouple generic, broadly applicable aspects of functions and classes (encoded in templates) from specific aspects (encoded in template parameters) without sacrificing performance due to abstraction. [230] => [231] => ===Objects=== [232] => {{Main|C++ classes}} [233] => C++ introduces [[object-oriented programming]] (OOP) features to C. It offers [[class (computer science)|class]]es, which provide the four features commonly present in OOP (and some non-OOP) languages: [[Abstraction (computer science)|abstraction]], [[Information hiding|encapsulation]], [[Inheritance (object-oriented programming)|inheritance]], and [[Polymorphism (computer science)|polymorphism]]. One distinguishing feature of {{nowrap|C++}} classes compared to classes in other programming languages is support for deterministic [[destructor (computer science)|destructors]], which in turn provide support for the [[Resource Acquisition is Initialization]] (RAII) concept. [234] => [235] => ====Encapsulation==== [236] => [[Information hiding|Encapsulation]] is the hiding of information to ensure that data structures and operators are used as intended and to make the usage model more obvious to the developer. C++ provides the ability to define classes and functions as its primary encapsulation mechanisms. Within a class, members can be declared as either public, protected, or private to explicitly enforce encapsulation. A public member of the class is accessible to any function. A private member is accessible only to functions that are members of that class and to functions and classes explicitly granted access permission by the class ("friends"). A protected member is accessible to members of classes that inherit from the class in addition to the class itself and any friends. [237] => [238] => The object-oriented principle ensures the encapsulation of all and only the functions that access the internal representation of a type. C++ supports this principle via member functions and friend functions, but it does not enforce it. Programmers can declare parts or all of the representation of a type to be public, and they are allowed to make public entities not part of the representation of a type. Therefore, C++ supports not just object-oriented programming, but other decomposition paradigms such as [[Modularity (programming)|modular programming]]. [239] => [240] => It is generally considered good practice to make all [[data]] private or protected, and to make public only those functions that are part of a minimal interface for users of the class. This can hide the details of data implementation, allowing the designer to later fundamentally change the implementation without changing the interface in any way.{{Cite book |first1=Herb |last1=Sutter |first2=Andrei |last2=Alexandrescu |author-link1=Herb Sutter |author-link2=Andrei Alexandrescu |year=2004 |title=C++ Coding Standards: 101 Rules, Guidelines, and Best Practices |publisher = Addison-Wesley }}{{Cite book |last1=Henricson |first1=Mats |last2=Nyquist |first2=Erik |title=Industrial Strength C++ |publisher=Prentice Hall |year=1997 |isbn=0-13-120965-5 |url=https://archive.org/details/industrialstreng0000henr }} [241] => [242] => ====Inheritance==== [243] => [[Inheritance (object-oriented programming)|Inheritance]] allows one data type to acquire properties of other data types. Inheritance from a [[base class]] may be declared as public, protected, or private. This access specifier determines whether unrelated and derived classes can access the inherited public and protected members of the base class. Only public inheritance corresponds to what is usually meant by "inheritance". The other two forms are much less frequently used. If the access specifier is omitted, a "class" inherits privately, while a "struct" inherits publicly. Base classes may be declared as virtual; this is called [[virtual inheritance]]. Virtual inheritance ensures that only one instance of a base class exists in the inheritance graph, avoiding some of the ambiguity problems of multiple inheritance. [244] => [245] => [[Multiple inheritance]] is a C++ feature allowing a class to be derived from more than one base class; this allows for more elaborate inheritance relationships. For example, a "Flying Cat" class can inherit from both "Cat" and "Flying Mammal". Some other languages, such as [[C Sharp (programming language)|C#]] or [[Java (programming language)|Java]], accomplish something similar (although more limited) by allowing inheritance of multiple [[Interface (object-oriented programming)|interfaces]] while restricting the number of base classes to one (interfaces, unlike classes, provide only declarations of member functions, no implementation or member data). An interface as in C# and Java can be defined in {{nowrap|C++}} as a class containing only pure virtual functions, often known as an [[abstract base class]] or "ABC". The member functions of such an abstract base class are normally explicitly defined in the derived class, not inherited implicitly. C++ virtual inheritance exhibits an ambiguity resolution feature called [[Dominance (C++)|dominance]]. [246] => [247] => ===Operators and operator overloading=== [248] => {| class="wikitable plainrowheaders floatright" [249] => |+ Operators that cannot be overloaded [250] => ! Operator [251] => ! Symbol [252] => |- [253] => | Scope resolution [254] => | {{cpp| ::}} [255] => |- [256] => | Conditional [257] => | {{cpp| ?:}} [258] => |- [259] => | dot [260] => | {{cpp| .}} [261] => |- [262] => | Member selection [263] => | {{cpp| .*}} [264] => |- [265] => | "[[sizeof]]" [266] => | {{cpp| sizeof}} [267] => |- [268] => | "[[typeid]]" [269] => | {{cpp| typeid}} [270] => |} [271] => [272] => {{Main|Operators in C and C++}} [273] => [274] => C++ provides more than 35 operators, covering basic arithmetic, bit manipulation, indirection, comparisons, logical operations and others. Almost all operators can be [[Operator overloading|overloaded]] for user-defined types, with a few notable exceptions such as member access (. and .*) and the conditional operator. The rich set of overloadable operators is central to making user-defined types in C++ seem like built-in types. [275] => [276] => Overloadable operators are also an essential part of many advanced C++ programming techniques, such as [[smart pointer]]s. Overloading an operator does not change the precedence of calculations involving the operator, nor does it change the number of operands that the operator uses (any operand may however be ignored by the operator, though it will be evaluated prior to execution). Overloaded "&&" and "||" operators lose their [[short-circuit evaluation]] property. [277] => [278] => ===Polymorphism=== [279] => {{See also|Polymorphism (computer science)}} [280] => [281] => [[Type polymorphism|Polymorphism]] enables one common interface for many implementations, and for objects to act differently under different circumstances. [282] => [283] => C++ supports several kinds of ''static'' (resolved at [[compile-time]]) and ''dynamic'' (resolved at [[Run time (program lifecycle phase)|run-time]]) [[polymorphism (computer science)|polymorphism]]s, supported by the language features described above. [[Compile-time polymorphism]] does not allow for certain run-time decisions, while [[runtime polymorphism]] typically incurs a performance penalty. [284] => [285] => ====Static polymorphism==== [286] => {{See also|Parametric polymorphism|ad hoc polymorphism}} [287] => [288] => [[Function overloading]] allows programs to declare multiple functions having the same name but with different arguments (i.e. [[ad hoc polymorphism|''ad hoc'' polymorphism]]). The functions are distinguished by the number or types of their [[Parameter (computer science)|formal parameter]]s. Thus, the same function name can refer to different functions depending on the context in which it is used. The type returned by the function is not used to distinguish overloaded functions and differing return types would result in a compile-time error message. [289] => [290] => When declaring a function, a programmer can specify for one or more parameters a [[default arguments|default value]]. Doing so allows the parameters with defaults to optionally be omitted when the function is called, in which case the default arguments will be used. When a function is called with fewer arguments than there are declared parameters, explicit arguments are matched to parameters in left-to-right order, with any unmatched parameters at the end of the parameter list being assigned their default arguments. In many cases, specifying default arguments in a single function declaration is preferable to providing overloaded function definitions with different numbers of parameters. [291] => [292] => [[Templates in C++]] provide a sophisticated mechanism for writing generic, polymorphic code (i.e. [[parametric polymorphism]]). In particular, through the [[curiously recurring template pattern]], it is possible to implement a form of static polymorphism that closely mimics the syntax for overriding virtual functions. Because C++ templates are type-aware and [[Turing-complete]], they can also be used to let the compiler resolve recursive conditionals and generate substantial programs through [[template metaprogramming]]. Contrary to some opinion, template code will not generate a bulk code after compilation with the proper compiler settings.{{cite web |access-date=8 March 2010 |publisher=EmptyCrate Software. Travel. Stuff. |location=articles.emptycrate.com/ |title=Nobody Understands C++: Part 5: Template Code Bloat |date=6 May 2008 |url=https://articles.emptycrate.com/2008/05/06/nobody_understands_c_part_5_template_code_bloat.html |quote=On occasion you will read or hear someone talking about C++ templates causing code bloat. I was thinking about it the other day and thought to myself, "self, if the code does exactly the same thing then the compiled code cannot really be any bigger, can it?" [...] And what about compiled code size? Each were compiled with the command g++ .cpp -O3. Non-template version: 8140 bytes, template version: 8028 bytes! |archive-date=25 April 2016 |archive-url=https://web.archive.org/web/20160425105303/http://articles.emptycrate.com/2008/05/06/nobody_understands_c_part_5_template_code_bloat.html |url-status=live }} [293] => [294] => ====Dynamic polymorphism==== [295] => [296] => =====Inheritance===== [297] => {{See also|Subtyping}} [298] => [299] => Variable pointers and references to a base class type in C++ can also refer to objects of any derived classes of that type. This allows arrays and other kinds of containers to hold pointers to objects of differing types (references cannot be directly held in containers). This enables dynamic (run-time) polymorphism, where the referred objects can behave differently, depending on their (actual, derived) types. [300] => [301] => C++ also provides the dynamic_cast operator, which allows code to safely attempt conversion of an object, via a base reference/pointer, to a more derived type: ''downcasting''. The ''attempt'' is necessary as often one does not know which derived type is referenced. (''Upcasting'', conversion to a more general type, can always be checked/performed at compile-time via static_cast, as ancestral classes are specified in the derived class's interface, visible to all callers.) dynamic_cast relies on [[run-time type information]] (RTTI), metadata in the program that enables differentiating types and their relationships. If a dynamic_cast to a pointer fails, the result is the nullptr constant, whereas if the destination is a reference (which cannot be null), the cast throws an exception. Objects ''known'' to be of a certain derived type can be cast to that with static_cast, bypassing RTTI and the safe runtime type-checking of dynamic_cast, so this should be used only if the programmer is very confident the cast is, and will always be, valid. [302] => [303] => =====Virtual member functions===== [304] => Ordinarily, when a function in a derived class [[Method overriding (programming)|overrides]] a function in a base class, the function to call is determined by the type of the object. A given function is overridden when there exists no difference in the number or type of parameters between two or more definitions of that function. Hence, at compile time, it may not be possible to determine the type of the object and therefore the correct function to call, given only a base class pointer; the decision is therefore put off until runtime. This is called [[dynamic dispatch]]. [[virtual functions|Virtual member functions]] or ''methods''{{Cite book |quote=A virtual member function is sometimes called a ''method''. |first=Bjarne |last=Stroustrup |year=2000 |page=310 |title=The C++ Programming Language |edition=Special |publisher=Addison-Wesley |isbn = 0-201-70073-5 }} allow the most specific implementation of the function to be called, according to the actual run-time type of the object. In C++ implementations, this is commonly done using [[virtual function table]]s. If the object type is known, this may be bypassed by prepending a [[fully qualified name|fully qualified class name]] before the function call, but in general calls to virtual functions are resolved at run time. [305] => [306] => In addition to standard member functions, operator overloads and destructors can be virtual. An inexact rule based on practical experience states that if any function in the class is virtual, the destructor should be as well. As the type of an object at its creation is known at compile time, constructors, and by extension copy constructors, cannot be virtual. Nonetheless, a situation may arise where a copy of an object needs to be created when a pointer to a derived object is passed as a pointer to a base object. In such a case, a common solution is to create a clone() (or similar) virtual function that creates and returns a copy of the derived class when called. [307] => [308] => A member function can also be made "pure virtual" by appending it with = 0 after the closing parenthesis and before the semicolon. A class containing a pure virtual function is called an ''abstract class''. Objects cannot be created from an abstract class; they can only be derived from. Any derived class inherits the virtual function as pure and must provide a non-pure definition of it (and all other pure virtual functions) before objects of the derived class can be created. A program that attempts to create an object of a class with a pure virtual member function or inherited pure virtual member function is ill-formed. [309] => [310] => ===Lambda expressions=== [311] => C++ provides support for [[anonymous function]]s, also known as [[Lambda calculus|lambda expressions]], with the following form: [312] => [313] => [314] => [capture](parameters) -> return_type { function_body } [315] => [316] => [317] => Since C++20, the keyword {{code|2=cpp|1=template}} is optional for template parameters of lambda expressions: [318] => [319] => [320] => [capture](parameters) -> return_type { function_body } [321] => [322] => [323] => If the lambda takes no parameters, and no return type or other specifiers are used, the () can be omitted; that is, [324] => [325] => [326] => [capture] { function_body } [327] => [328] => [329] => The return type of a lambda expression can be automatically inferred, if possible; e.g.: [330] => [331] => [332] => [](int x, int y) { return x + y; } // inferred [333] => [](int x, int y) -> int { return x + y; } // explicit [334] => [335] => [336] => The [capture] list supports the definition of [[Closure (computer programming)|closures]]. Such lambda expressions are defined in the standard as [[syntactic sugar]] for an unnamed [[function object]]. [337] => [338] => ===Exception handling=== [339] => Exception handling is used to communicate the existence of a runtime problem or error from where it was detected to where the issue can be handled.{{Cite web|url = http://www.cl.cam.ac.uk/teaching/1314/CandC++/lecture7.pdf|title = C and C++ Exceptions | Templates|date = 2013|access-date = 30 August 2016|website = Cambridge Computer Laboratory - Course Materials 2013-14|last = Mycroft|first = Alan|archive-date = 13 May 2016|archive-url = https://web.archive.org/web/20160513074615/http://www.cl.cam.ac.uk/teaching/1314/CandC++/lecture7.pdf|url-status = live}} It permits this to be done in a uniform manner and separately from the main code, while detecting all errors.{{Cite book|title = The C++ Programming Language|last = Stroustrup|first = Bjarne|publisher = Addison Wesley|year = 2013|isbn = 9780321563842|pages = 345}} Should an error occur, an exception is thrown (raised), which is then caught by the nearest suitable exception handler. The exception causes the current scope to be exited, and also each outer scope (propagation) until a suitable handler is found, calling in turn the destructors of any objects in these exited scopes.{{Cite book|title = The C++ Programming Language|last = Stroustrup|first = Bjarne|publisher = Addison Wesley|year = 2013|isbn = 9780321563842|pages = 363–365}} At the same time, an exception is presented as an object carrying the data about the detected problem.{{Cite book|title = The C++ Programming Language|last = Stroustrup|first = Bjarne|publisher = Addison Wesley|year = 2013|isbn = 9780321563842|pages = 345, 363}} [340] => [341] => Some C++ style guides, such as Google's,{{cite web |title=Google C++ Style Guide |url=https://google.github.io/styleguide/cppguide.html#Exceptions |access-date=25 June 2019 |archive-date=16 March 2019 |archive-url=https://web.archive.org/web/20190316065327/http://google.github.io/styleguide/cppguide.html#Exceptions |url-status=live }} LLVM's,{{cite web |title=LLVM Coding Standards |url=https://llvm.org/docs/CodingStandards.html#do-not-use-rtti-or-exceptions |website=LLVM 9 documentation |access-date=25 June 2019 |archive-date=27 June 2019 |archive-url=https://web.archive.org/web/20190627023217/http://llvm.org/docs/CodingStandards.html#do-not-use-rtti-or-exceptions |url-status=live }} and Qt's,{{cite web |title=Coding Conventions |url=https://wiki.qt.io/Coding_Conventions |website=Qt Wiki |access-date=26 June 2019 |archive-date=26 June 2019 |archive-url=https://web.archive.org/web/20190626231458/https://wiki.qt.io/Coding_Conventions |url-status=live }} forbid the usage of exceptions. [342] => [343] => The exception-causing code is placed inside a try block. The exceptions are handled in separate catch blocks (the handlers); each try block can have multiple exception handlers, as it is visible in the example below.{{Cite book|title = The C++ Programming Language|last = Stroustrup|first = Bjarne|publisher = Addison Wesley|year = 2013|isbn = 9780321563842|pages = 344, 370}} [344] => [345] => [346] => #include [347] => #include [348] => #include [349] => [350] => int main() { [351] => try { [352] => std::vector vec{3, 4, 3, 1}; [353] => int i{vec.at(4)}; // Throws an exception, std::out_of_range (indexing for vec is from 0-3 not 1-4) [354] => } [355] => // An exception handler, catches std::out_of_range, which is thrown by vec.at(4) [356] => catch (const std::out_of_range &e) { [357] => std::cerr << "Accessing a non-existent element: " << e.what() << '\n'; [358] => } [359] => // To catch any other standard library exceptions (they derive from std::exception) [360] => catch (const std::exception &e) { [361] => std::cerr << "Exception thrown: " << e.what() << '\n'; [362] => } [363] => // Catch any unrecognised exceptions (i.e. those which don't derive from std::exception) [364] => catch (...) { [365] => std::cerr << "Some fatal error\n"; [366] => } [367] => } [368] => [369] => [370] => It is also possible to raise exceptions purposefully, using the throw keyword; these exceptions are handled in the usual way. In some cases, exceptions cannot be used due to technical reasons. One such example is a critical component of an embedded system, where every operation must be guaranteed to complete within a specified amount of time. This cannot be determined with exceptions as no tools exist to determine the maximum time required for an exception to be handled.{{Cite book|title = The C++ Programming Language|last = Stroustrup|first = Bjarne|publisher = Addison Wesley|year = 2013|isbn = 9780321563842|pages = 349}} [371] => [372] => Unlike [[Signal handler|signal handling]], in which the handling function is called from the point of failure, exception handling exits the current scope before the catch block is entered, which may be located in the current function or any of the previous function calls currently on the stack. [373] => [374] => ===Enumerated types=== [375] => {{excerpt|Enumerated type|C++}} [376] => [377] => ==Standard library== [378] => [[File:ANSI ISO C++ WP.jpg|thumb|right|The draft "Working Paper" standard that became approved as C++98; half of its size was devoted to the C++ Standard Library.]] [379] => {{Main|C++ Standard Library}} [380] => The C++ [[standardization|standard]] consists of two parts: the core language and the standard library. C++ programmers expect the latter on every major implementation of C++; it includes aggregate types ([[sequence container (C++)#Vector|vectors]], lists, maps, sets, queues, stacks, arrays, tuples), [[algorithm]]s (find, [[Foreach loop|for_each]], [[Binary search algorithm|binary_search]], random_shuffle, etc.), input/output facilities ([[iostream]], for reading from and writing to the console and files), filesystem library, localisation support, [[smart pointers]] for automatic memory management, [[regular expression]] support, [[multithreading (software)|multi-threading]] library, atomics support (allowing a variable to be read or written to by at most one thread at a time without any external synchronisation), time utilities (measurement, getting current time, etc.), a system for converting error reporting that does not use C++ [[exception handling|exceptions]] into C++ exceptions, a [[random number generator]], and a slightly modified version of the [[C standard library]] (to make it comply with the C++ type system). [381] => [382] => A large part of the C++ library is based on the [[Standard Template Library]] (STL). Useful tools provided by the STL include [[container (data structure)|container]]s as the collections of objects (such as [[array data structure|vector]]s and [[linked list|lists]]), [[iterator]]s that provide array-like access to containers, and [[algorithm]]s that perform operations such as searching and sorting. [383] => [384] => Furthermore, (multi)maps ([[associative array]]s) and (multi)sets are provided, all of which export compatible interfaces. Therefore, using templates it is possible to write generic algorithms that work with any container or on any sequence defined by iterators. As in C, the [[feature (software design)|feature]]s of the [[library (computing)|library]] are accessed by using the #include [[directive (programming)|directive]] to include a [[standard header]]. The [[C++ Standard Library]] provides 105 standard headers, of which 27 are deprecated. [385] => [386] => The standard incorporates the STL that was originally designed by [[Alexander Stepanov]], who experimented with generic algorithms and containers for many years. When he started with C++, he finally found a language where it was possible to create generic algorithms (e.g., STL sort) that perform even better than, for example, the C standard library qsort, thanks to C++ features like using inlining and compile-time binding instead of function pointers. The standard does not refer to it as "STL", as it is merely a part of the standard library, but the term is still widely used to distinguish it from the rest of the standard library (input/output streams, internationalization, diagnostics, the C library subset, etc.).{{cite web |url=http://www.stlport.org/resources/StepanovUSA.html |author=Graziano Lo Russo |title=An Interview with A. Stepanov |year=2008 |access-date=8 October 2015 |website=stlport.org |archive-date=4 March 2009 |archive-url=https://web.archive.org/web/20090304120628/http://www.stlport.org/resources/StepanovUSA.html |url-status=live }} [387] => [388] => Most C++ compilers, and all major ones, provide a standards-conforming implementation of the C++ standard library. [389] => [390] => ==C++ Core Guidelines== [391] => The C++ Core Guidelines{{Cite web|url=https://isocpp.github.io/CppCoreGuidelines/|title=C++ Core Guidelines|website=isocpp.github.io|access-date=9 February 2020|archive-date=16 February 2020|archive-url=https://web.archive.org/web/20200216200622/http://isocpp.github.io/CppCoreGuidelines/|url-status=live}} are an initiative led by Bjarne Stroustrup, the inventor of C++, and Herb Sutter, the convener and chair of the C++ ISO Working Group, to help programmers write 'Modern C++' by using best practices for the language standards C++11 and newer, and to help developers of compilers and static checking tools to create rules for catching bad programming practices. [392] => [393] => The main aim is to efficiently and consistently write type and resource safe C++. [394] => [395] => The Core Guidelines were announced{{Cite web|url=https://isocpp.org/blog/2015/09/bjarne-stroustrup-announces-cpp-core-guidelines|title=Bjarne Stroustrup announces C++ Core Guidelines : Standard C++|website=isocpp.org|access-date=31 March 2020|archive-date=11 May 2020|archive-url=https://web.archive.org/web/20200511035635/https://isocpp.org/blog/2015/09/bjarne-stroustrup-announces-cpp-core-guidelines|url-status=live}} in the opening keynote at CPPCon 2015. [396] => [397] => The Guidelines are accompanied by the Guideline Support Library (GSL),{{Cite web|url=https://github.com/microsoft/GSL|title=microsoft/GSL|date=18 July 2021|via=GitHub|access-date=18 July 2021|archive-date=18 July 2021|archive-url=https://web.archive.org/web/20210718130829/https://github.com/microsoft/GSL|url-status=live}} a header only library of types and functions to implement the Core Guidelines and static checker tools for enforcing Guideline rules.{{Cite web|url=https://docs.microsoft.com/en-us/cpp/code-quality/using-the-cpp-core-guidelines-checkers|title=Using the C++ Core Guidelines checkers|website=Microsoft Learn |access-date=31 March 2020|archive-date=13 August 2021|archive-url=https://web.archive.org/web/20210813193329/https://docs.microsoft.com/en-us/cpp/code-quality/using-the-cpp-core-guidelines-checkers?view=msvc-160|url-status=live}} [398] => [399] => ==Compatibility== [400] => To give compiler vendors greater freedom, the C++ standards committee decided not to dictate the implementation of [[name mangling]], [[exception handling]], and other implementation-specific features. The downside of this decision is that [[object code]] produced by different [[compiler]]s is expected to be incompatible. There are, however, attempts to standardize compilers for particular machines or [[operating system]]s. For example, the Itanium C++ ABI is processor-independent (despite its name) and is implemented by GCC and Clang.{{cite web |url=https://mentorembedded.github.io/cxx-abi/ |title=C++ ABI Summary |date=20 March 2001 |access-date=30 May 2006 |archive-date=10 July 2018 |archive-url=https://web.archive.org/web/20180710195559/https://mentorembedded.github.io/cxx-abi/ |url-status=live }} [401] => [402] => ===With C=== [403] => {{Further|Compatibility of C and C++}} [404] => C++ is often considered to be a superset of [[C (programming language)|C]] but this is not strictly true.{{cite web |url=http://www.stroustrup.com/bs_faq.html#C-is-subset |title=Bjarne Stroustrup's FAQ – Is C a subset of C++? |access-date=5 May 2014 |archive-date=6 February 2016 |archive-url=https://web.archive.org/web/20160206214150/http://www.stroustrup.com/bs_faq.html#C-is-subset |url-status=live }} Most C code can easily be made to compile correctly in C++ but there are a few differences that cause some valid C code to be invalid or behave differently in C++. For example, C allows implicit conversion from void* to other pointer types but C++ does not (for type safety reasons). Also, C++ defines many new keywords, such as new and class, which may be used as identifiers (for example, variable names) in a C program. [405] => [406] => Some incompatibilities have been removed by the 1999 revision of the C standard ([[C99]]), which now supports C++ features such as line comments (//) and declarations mixed with code. On the other hand, C99 introduced a number of new features that C++ did not support that were incompatible or redundant in C++, such as [[variable-length array]]s, native complex-number types (however, the std::complex class in the C++ standard library provides similar functionality, although not code-compatible), designated initializers, [[C syntax#Compound literals|compound literals]], and the restrict keyword.{{cite web |url=http://home.datacomm.ch/t_wolf/tw/c/c9x_changes.html |title=C9X – The New C Standard |access-date=27 December 2008 |archive-date=21 June 2018 |archive-url=https://web.archive.org/web/20180621084656/http://home.datacomm.ch/t_wolf/tw/c/c9x_changes.html |url-status=live }} Some of the C99-introduced features were included in the subsequent version of the C++ standard, [[C++11#Improved C compatibility|C++11]] (out of those which were not redundant).{{cite web |title=C++0x Support in GCC |url=https://gcc.gnu.org/projects/cxx0x.html |access-date=12 October 2010 |archive-date=21 July 2010 |archive-url=https://web.archive.org/web/20100721215324/http://gcc.gnu.org/projects/cxx0x.html |url-status=live }}{{cite web |title=C++0x Core Language Features In VC10: The Table |url=https://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx |access-date=12 October 2010 |archive-date=21 August 2010 |archive-url=https://web.archive.org/web/20100821114635/http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx |url-status=live }}{{cite web |url=https://clang.llvm.org/cxx_status.html |title=Clang - C++98, C++11, and C++14 Status |publisher=Clang.llvm.org |date=12 May 2013 |access-date=10 June 2013 |archive-date=4 July 2013 |archive-url=https://web.archive.org/web/20130704124639/http://clang.llvm.org/cxx_status.html |url-status=live }} However, the C++11 standard introduces new incompatibilities, such as disallowing assignment of a string literal to a character pointer, which remains valid C. [407] => [408] => To intermix C and C++ code, any function declaration or definition that is to be called from/used both in C and C++ must be declared with C linkage by placing it within an extern "C" {/*...*/} block. Such a function may not rely on features depending on [[name mangling]] (i.e., function overloading). [409] => [410] => ==Criticism== [411] => {{Main|Criticism of C++}} [412] => Despite its widespread adoption, some notable programmers have criticized the C++ language, including [[Linus Torvalds]],{{cite mailing list |url=https://lwn.net/Articles/249460/ |title=Re: [RFC] Convert builin-mailinfo.c to use The Better String Library |date=6 September 2007 |access-date=31 March 2015 |archive-date=8 March 2021 |archive-url=https://web.archive.org/web/20210308222938/https://lwn.net/Articles/249460/ |url-status=live }} [[Richard Stallman]],{{cite mailing list |url=http://harmful.cat-v.org/software/c++/rms |title=Re: Efforts to attract more users? |date=12 July 2010 |access-date=31 March 2015 |archive-date=21 March 2015 |archive-url=https://web.archive.org/web/20150321233514/http://harmful.cat-v.org/software/c%20%20/rms |url-status=live }} [[Joshua Bloch]], [[Ken Thompson]],{{cite web |url=https://www.drdobbs.com/open-source/interview-with-ken-thompson/229502480 |title=Dr. Dobb's: Interview with Ken Thompson |author=Andrew Binstock |date=18 May 2011 |access-date=7 February 2014 |archive-date=13 March 2014 |archive-url=https://web.archive.org/web/20140313072938/http://www.drdobbs.com/open-source/interview-with-ken-thompson/229502480 |url-status=live }}{{cite book|author=Peter Seibel|title=Coders at Work: Reflections on the Craft of Programming|url=https://books.google.com/books?id=nneBa6-mWfgC&pg=PA475|date=16 September 2009|publisher=Apress|isbn=978-1-4302-1948-4|pages=475–476|access-date=9 November 2017|archive-date=1 December 2019|archive-url=https://web.archive.org/web/20191201142309/https://books.google.com/books?id=nneBa6-mWfgC&pg=PA475|url-status=live}}{{Cite web|url=https://gigamonkeys.wordpress.com/2009/10/16/coders-c-plus-plus/|title=C++ in Coders at Work|date=16 October 2009|access-date=9 November 2017|archive-date=10 November 2017|archive-url=https://web.archive.org/web/20171110061643/https://gigamonkeys.wordpress.com/2009/10/16/coders-c-plus-plus/|url-status=live}} and [[Donald Knuth]].{{Cite web|url=http://www.drdobbs.com/architecture-and-design/an-interview-with-donald-knuth/228700500|title=An Interview with Donald Knuth|website=Dr. Dobb's|access-date=18 July 2021|archive-date=8 March 2021|archive-url=https://web.archive.org/web/20210308031011/https://www.drdobbs.com/architecture-and-design/an-interview-with-donald-knuth/228700500|url-status=live}}{{Cite web |url=http://tex.loria.fr/litte/knuth-interview |title=(La)TeX Navigator |access-date=10 November 2017 |archive-date=20 November 2017 |archive-url=https://web.archive.org/web/20171120163257/http://tex.loria.fr/litte/knuth-interview |url-status=live }} [413] => [414] => One of the most often criticised points of C++ is its perceived complexity as a language, with the criticism that a large number of non-orthogonal features in practice necessitates restricting code to a subset of C++, thus eschewing the readability benefits of common style and idioms. As expressed by [[Joshua Bloch]]:
I think C++ was pushed well beyond its complexity threshold, and yet there are a lot of people programming it. But what you do is you force people to subset it. So almost every shop that I know of that uses C++ says, "Yes, we're using C++ but we're not doing multiple-implementation inheritance and we're not using operator overloading." There are just a bunch of features that you're not going to use because the complexity of the resulting code is too high. And I don't think it's good when you have to start doing that. You lose this programmer portability where everyone can read everyone else's code, which I think is such a good thing.
[415] => [416] => [[Donald Knuth]] (1993, commenting on pre-standardized C++), who said of [[Edsger Dijkstra]] that "to think of programming in C++" "would make him physically ill":
The problem that I have with them today is that... C++ is too complicated. At the moment, it's impossible for me to write portable code that I believe would work on lots of different systems, unless I avoid all exotic features. Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said "OK, we'll do them both". So the language is too baroque for my taste.
[417] => [418] => [[Ken Thompson]], who was a colleague of Stroustrup at Bell Labs, gives his assessment:
It certainly has its good points. But by and large I think it's a bad language. It does a lot of things half well and it's just a garbage heap of ideas that are mutually exclusive. Everybody I know, whether it's personal or corporate, selects a subset and these subsets are different. So it's not a good language to transport an algorithm—to say, "I wrote it; here, take it." It's way too big, way too complex. And it's obviously [[Design by committee|built by a committee]]. [419] => Stroustrup campaigned for years and years and years, way beyond any sort of technical contributions he made to the language, to get it adopted and used. And he sort of ran all the standards committees with a whip and a chair. And he said "no" to no one. He put every feature in that language that ever existed. It wasn't cleanly designed—it was just the union of everything that came along. And I think it suffered drastically from that.
[420] => [421] => However [[Brian Kernighan]], also a colleague at Bell Labs, disputes this assessment:{{cite video|people=Brian Kernighan|date=July 18, 2018|title=Brian Kernighan Q&A - Computerphile|url=https://www.youtube.com/watch?v=zmYhR8cUX90&t=5m17s| archive-url=https://ghostarchive.org/varchive/zmYhR8cUX90?url=https://www.youtube.com/watch?v=zmYhR8cUX90| archive-date=2021-09-25}}{{cbignore}}
C++ has been enormously influential. ... Lots of people say C++ is too big and too complicated etc. etc. but in fact it is a very powerful language and pretty much everything that is in there is there for a really sound reason: it is not somebody doing random invention, it is actually people trying to solve real world problems. Now a lot of the programs that we take for granted today, that we just use, are C++ programs.
[422] => [423] => Stroustrup himself comments that C++ semantics are much cleaner than its syntax: "within C++, there is a much smaller and cleaner language struggling to get out."{{Cite web|url=http://www.stroustrup.com/bs_faq.html#really-say-that|title=Stroustrup: FAQ|website=www.stroustrup.com|access-date=7 June 2013|archive-date=6 February 2016|archive-url=https://web.archive.org/web/20160206214150/http://www.stroustrup.com/bs_faq.html#really-say-that|url-status=live}} [424] => [425] => Other complaints may include a lack of [[reflection (computer programming)|reflection]] or [[garbage collection (computer science)|garbage collection]], long compilation times, perceived [[feature creep]],{{cite web |url=https://commandcenter.blogspot.mx/2012/06/less-is-exponentially-more.html |title=Less is exponentially more |year=2012 |last=Pike |first=Rob |access-date=23 November 2018 |archive-date=7 July 2017 |archive-url=https://web.archive.org/web/20170707160721/https://commandcenter.blogspot.mx/2012/06/less-is-exponentially-more.html |url-status=live }} and verbose error messages, particularly from template metaprogramming.{{cite web|url=https://yosefk.com/c++fqa/defective.html|title=Defective C++|first=Yossi|last=Kreinin|date=13 October 2009|access-date=3 February 2016|archive-date=5 February 2016|archive-url=https://web.archive.org/web/20160205204200/http://yosefk.com/c++fqa/defective.html|url-status=live}} [426] => [427] => ==See also== [428] => {{Portal|Computer programming}} [429] => * [[Comparison of programming languages]] [430] => * [[List of C++ compilers]] [431] => * [[Outline of C++]] [432] => * [[:Category:C++ libraries]] [433] => [434] => ==Footnotes== [435] => {{Reflist|group=note}} [436] => {{Clear|right}} [437] => [438] => ==References== [439] => {{Reflist}} [440] => [441] => ==Further reading== [442] => {{Refbegin|30em}} [443] => * {{Cite book |first1=David |last1=Abrahams |author-link=David Abrahams (computer programmer) |first2=Aleksey |last2=Gurtovoy |title=C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond |year=2005 |publisher=Addison-Wesley |isbn=0-321-22725-5 }} [444] => * {{Cite book |first=Andrei |last=Alexandrescu |author-link=Andrei Alexandrescu |year=2001 |title=Modern C++ Design: Generic Programming and Design Patterns Applied |publisher=Addison-Wesley |isbn=0-201-70431-5 }} [445] => * {{Cite book |first1=Andrei |last1=Alexandrescu |author-link=Andrei Alexandrescu |first2=Herb |last2=Sutter |author-link2=Herb Sutter|year=2004 |title=C++ Design and Coding Standards: Rules and Guidelines for Writing Programs |publisher=Addison-Wesley |isbn=0-321-11358-6 }} [446] => * {{Cite book |first=Pete |last=Becker |author-link=Pete Becker |year=2006 |title=The C++ Standard Library Extensions : A Tutorial and Reference |publisher=Addison-Wesley |isbn=0-321-41299-0 }} [447] => * {{Cite book |first=Frank |last=Brokken |year=2010 |title=C++ Annotations |publisher=University of Groningen |isbn=978-90-367-0470-0 |url=http://www.icce.rug.nl/documents/cplusplus/ |access-date=28 April 2010 |archive-date=28 April 2010 |archive-url=https://web.archive.org/web/20100428014354/http://www.icce.rug.nl/documents/cplusplus/ |url-status=live }} [448] => * {{Cite book |first=James O. |last=Coplien |author-link=James O. Coplien |orig-year=reprinted with corrections, original year of publication 1992 |date=1994 |title=Advanced C++: Programming Styles and Idioms |isbn=0-201-54855-0 |url=https://archive.org/details/advancedcbsprogr00copl }} [449] => * {{Cite book |first=Stephen C. |last=Dewhurst |year=2005 |title=C++ Common Knowledge: Essential Intermediate Programming |publisher=Addison-Wesley |isbn=0-321-32192-8 }} [450] => * {{Cite book |author=Information Technology Industry Council |author-link=Information and Communications Technology Council |publisher=ISO/IEC |location=Geneva |title=Programming languages – C++ |id=14882:2003(E) |edition=Second |date=15 October 2003 }} [451] => * {{Cite book |first=Nicolai M. |last=Josuttis |title=The C++ Standard Library, A Tutorial and Reference |edition=Second|year=2012 |publisher=Addison-Wesley |isbn=978-0-321-62321-8}} [452] => * {{Cite book |first1=Andrew |last1=Koenig |author-link=Andrew Koenig (programmer) |first2=Barbara E. |last2=Moo |year=2000 |title=Accelerated C++ – Practical Programming by Example |publisher=Addison-Wesley |isbn=0-201-70353-X |url=https://archive.org/details/acceleratedcprac2000koen }} [453] => * {{Cite book |first1=Stanley B. |last1=Lippman |author-link=Stanley B. Lippman |first2=Josée |last2=Lajoie |first3=Barbara E. |last3=Moo |year=2011 |edition=Fifth |title=C++ Primer |url=https://archive.org/details/cprimer0000lipp_5thed |url-access=registration |publisher=Addison-Wesley |isbn=978-0-321-71411-4 }} [454] => * {{Cite book |first=Stanley B. |last=Lippman |year=1996 |title=Inside the C++ Object Model |publisher=Addison-Wesley |isbn=0-201-83454-5 }} [455] => * {{Cite book |first=Scott |last=Meyers |author-link=Scott Meyers |year=2005 |title=Effective C++ |edition=Third |publisher=Addison-Wesley |isbn=0-321-33487-6 |url=https://archive.org/details/effectivec55spec00meye }} [456] => * {{Cite book |first=Bjarne |last=Stroustrup|author-link=Bjarne Stroustrup |year=2013 |title=[[The C++ Programming Language]] |edition=Fourth |publisher=Addison-Wesley |isbn=978-0-321-56384-2 }} [457] => * {{Cite book |first=Bjarne |last=Stroustrup|author-link=Bjarne Stroustrup |year=1994 |title=[[The Design and Evolution of C++]] |publisher=Addison-Wesley |isbn=0-201-54330-3 }} [458] => * {{Cite book |first=Bjarne |last=Stroustrup|author-link=Bjarne Stroustrup|year=2014 |title=Programming: Principles and Practice Using C++ |edition=Second |publisher=Addison-Wesley |isbn=978-0-321-99278-9 }} [459] => * {{Cite book |first=Herb |last=Sutter|author-link=Herb Sutter |year=2001 |title=More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions |publisher=Addison-Wesley |isbn=0-201-70434-X }} [460] => * {{Cite book |first=Herb |last=Sutter|author-link=Herb Sutter |year=2004 |title=Exceptional C++ Style |publisher=Addison-Wesley |isbn=0-201-76042-8 }} [461] => * {{Cite book |first1=David |last1=Vandevoorde |first2=Nicolai M. |last2=Josuttis |year=2003 |title=C++ Templates: The complete Guide |publisher=Addison-Wesley |isbn=0-201-73484-2 }} [462] => {{refend}} [463] => [464] => ==External links== [465] => * [http://www.open-std.org/jtc1/sc22/wg21/ JTC1/SC22/WG21] – the ISO/IEC C++ Standard Working Group [466] => * [https://isocpp.org/ Standard C++ Foundation] – a non-profit organization that promotes the use and understanding of standard C++. [[Bjarne Stroustrup]] is a director of the organization. [467] => [468] => {{Sister bar|auto=1}} [469] => {{C++ programming language}} [470] => {{Programming languages}} [471] => {{ISO standards}} [472] => {{List of International Electrotechnical Commission standards}} [473] => {{Authority control}} [474] => [475] => {{DEFAULTSORT:C}} [476] => [[Category:C++| ]] [477] => [[Category:Algol programming language family]] [478] => [[Category:C++ programming language family]] [479] => [[Category:Class-based programming languages]] [480] => [[Category:Cross-platform software]] [481] => [[Category:High-level programming languages]] [482] => [[Category:Object-oriented programming languages]] [483] => [[Category:Programming languages created in 1983]] [484] => [[Category:Programming languages with an ISO standard]] [485] => [[Category:Statically typed programming languages]] [486] => [[Category:Compiled programming languages]] [] => )
good wiki

C++

C++ is a general-purpose programming language that was developed in 1979 by Bjarne Stroustrup. It is an extension of the C programming language and allows for high-level programming while still being efficient and close to the hardware.

More about us

About

It is an extension of the C programming language and allows for high-level programming while still being efficient and close to the hardware. C++ was designed with the aim of providing a strong support for systems programming, and has since been used for various applications, including game development, software engineering, and scientific research. This programming language offers a wide range of features, such as object-oriented programming, generic programming, and exception handling, making it versatile and powerful. C++ has also influenced the development of other programming languages, such as Java and C#. This Wikipedia page provides comprehensive information on the history, features, syntax, and applications of C++, along with examples and external resources for further reading.

Expert Team

Vivamus eget neque lacus. Pellentesque egauris ex.

Award winning agency

Lorem ipsum, dolor sit amet consectetur elitorceat .

10 Year Exp.

Pellen tesque eget, mauris lorem iupsum neque lacus.