欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
C++
小 (→C++标准) |
|||
(未显示2个用户的78个中间版本) | |||
第1行: | 第1行: | ||
+ | {{SeeWikipedia}} | ||
+ | |||
+ | [[文件:Cpp-logo.png|right|C++]] | ||
+ | |||
+ | C++ | ||
+ | |||
+ | ==简介== | ||
+ | C++ 是世界上最流行的系统级语言 | ||
+ | |||
+ | C++语言是一种应用较广的面向对象的程序设计语言,使用它可以实现面向对象的程序设计。面向对象的设计与面向过程的设计是有很大区别的,面向对象的程序设计是在面向过程的程序设计的基础上一个质的飞跃。要学会面向对象的程序设计,首先要学会一种面向对象的语言,即要学会用VC编程,就要先有C++的基础,而学习C++语言首先要认识它面向对象的特性和实现面向对象的方法。 | ||
+ | |||
第一个 C++ 程序 | 第一个 C++ 程序 | ||
+ | #include <iostream> | ||
+ | int main() | ||
+ | { | ||
+ | std::cout << "hello, world\n"; | ||
+ | } | ||
+ | |||
+ | *[http://docs.huihoo.com/cppreference/all_cpp_functions.html All C++ Functions] | ||
+ | *[http://docs.huihoo.com/cppreference/all_c_functions.html All C Functions] | ||
+ | |||
+ | ==历史== | ||
+ | *C++ 语言设计受到了 Simula 的重要影响,[http://www.simula67.info/ Simula] 一种编译式的编程语言,由奥利-约翰·达尔与克利斯登·奈加特,在1960年代于奥斯陆的挪威计算中心,开发出来了 Simula I 与 Simula 67 两代。它承继了 ALGOL 60 的基础,被认为是第一个面向对象编程的编程语言。 | ||
+ | *[https://www.stroustrup.com/hopl2.pdf A History of C++: 1979−1991] | ||
+ | |||
+ | ==C++标准== | ||
+ | C++主要版本:1998, 2003, 2011, 2014, 2017, 2020 | ||
+ | |||
+ | [https://github.com/cplusplus/draft C++ standards drafts] | ||
+ | *2020,ISO/IEC 14882:2020, C++20, 第六个C++标准 | ||
+ | *2017, ISO/IEC 14882:2017, C++17, 第五个C++标准 | ||
+ | *2014, ISO/IEC 14882:2014, C++14, 第四个C++标准 | ||
+ | *2011, ISO/IEC 14882:2011, C++11, 第三个C++标准 | ||
+ | *2003, ISO/IEC 14882:2003, C++03, 第二个C++标准 | ||
+ | *1998, ISO/IEC 14882:1998, C++98, 第一个C++标准 | ||
+ | [http://imcc.blogbus.com/logs/107678844.html C++标准的运作方式]:ISO标准委员会,[http://www.open-std.org/jtc1/sc22/wg21/ SC22 WG21],是在ISO规则下运行的。奇怪的是,这些规则并非标准化的,而是随着时间的变化而变化。(译注:标准委员会的规则并不标准)。大多数国家都有活跃的C++团体并形成了自己的国家标准。这些团体举行会议,通过网络协调一致,并向ISO会议推选代表。加拿大,法国,德国,瑞士,英国和美国是出席这些会议较多的国家。丹麦,荷兰,日本,挪威,西班牙和别的一些国家则是出席人数比较少的国家。大多数通过网络召开的会议都是介于这两者之间,会议记录由标准委员会编号并存放在 WG21。 | ||
+ | |||
+ | 标准委员会每年召开两到三次会议,每次约一周的时间。这些会议的大部分工作就是工作划分,比如“核心“,”库“,”演化“,“并发”。根据需要,也会为了解决一些迫切的问题而召开会议,比如“概念”和“内存模型”。会议主要用来投票表决。首先,工作组举行民意投票来判断某个论点是否可以作为一个整体提案递交给标准委员会。然后,如果这个提案被接受,标准委员会将进行每人一票的投票表决。我们花费大量注意力在那些我们没有进入但是已经有很多人表现出来和国家不同意的形势--这将会导致长期的争论。最后,官方草案的投票由国家标准机构通过邮件完成。标准委员会和C标准组织以及POSIX有正式的联系,并和其他一些组织也有或多或少的联系。 | ||
+ | |||
+ | 标准委员会包括大约200个人,其中有大约60位会出席每年两到三次一周时间的会议。除此之外,在一些国家还有一些国家标准组织和会议。多数成员通过出席会议,邮件讨论或提交论文供标准委员会斟酌等方式贡献自己的力量。多数成员有朋友或同事提供帮助。第一天,标准委员会召集从各个国家而来的代表,并且每一次会议由6到12个国家的代表参加。最终投票由20个国家标准组织完成。 | ||
+ | *C++20 | ||
+ | *[[C++17]] | ||
+ | *[[C++14]] | ||
+ | *[[C++11]] | ||
+ | *[http://www.open-std.org/JTC1/SC22/WG21/ WG21 - C++] | ||
+ | *[http://www2.research.att.com/~bs/C++0xFAQ.html C++0x - the next ISO C++ standard] | ||
+ | *[http://imcc.blogbus.com/logs/106046323.html C++0x FAQ中文版] | ||
+ | |||
+ | ==状态== | ||
+ | <gallery> | ||
+ | image:cpp-wg21-timeline.png | ||
+ | </gallery> | ||
+ | |||
+ | *[https://github.com/fffaraz/awesome-cpp Awesome C/C++] [[文件:awesome.png]] | ||
+ | *[https://github.com/rigtorp/awesome-modern-cpp Awesome Modern C++] | ||
+ | |||
+ | ==Library== | ||
+ | Standard C++ library headers listed below, 13 constitute the Standard Template Library, or STL. | ||
+ | *<algorithm> -- (STL) for defining numerous templates that implement useful algorithms | ||
+ | *<bitset> -- for defining a template class that administers sets of bits | ||
+ | *<cassert> -- for enforcing assertions when functions execute | ||
+ | *<cctype> -- for classifying characters | ||
+ | *<cerrno> -- for testing error codes reported by library functions | ||
+ | *<cfloat> -- for testing floating-point type properties | ||
+ | *<ciso646> -- for programming in ISO 646 variant character sets | ||
+ | *<climits> -- for testing integer type properties | ||
+ | *<clocale> -- for adapting to different cultural conventions | ||
+ | *<cmath> -- for computing common mathematical functions | ||
+ | *<complex> -- for defining a template class that supports complex arithmetic | ||
+ | *<csetjmp> -- for executing nonlocal goto statements | ||
+ | *<csignal> -- for controlling various exceptional conditions | ||
+ | *<cstdarg> -- for accessing a varying number of arguments | ||
+ | *<cstddef> -- for defining several useful types and macros | ||
+ | *<cstdio> -- for performing input and output | ||
+ | *<cstdlib> -- for performing a variety of operations | ||
+ | *<cstring> -- for manipulating several kinds of strings | ||
+ | *<ctime> -- for converting between various time and date formats | ||
+ | *<cwchar> -- for manipulating wide streams and several kinds of strings | ||
+ | *<cwctype> -- for classifying wide characters | ||
+ | *<deque> -- (STL) for defining a template class that implements a deque container | ||
+ | *<exception> -- for defining several functions that control exception handling | ||
+ | *<fstream> -- for defining several iostreams template classes that manipulate external files | ||
+ | *<functional> -- (STL) for defining several templates that help construct predicates for the templates defined in <algorithm> and <numeric> | ||
+ | *<iomanip> -- for declaring several iostreams manipulators that take an argument | ||
+ | *<ios> -- for defining the template class that serves as the base for many iostreams classes | ||
+ | *<iosfwd> -- for declaring several iostreams template classes before they are necessarily defined | ||
+ | *<iostream> -- for declaring the iostreams objects that manipulate the standard streams | ||
+ | *<istream> -- for defining the template class that performs extractions | ||
+ | *<iterator> -- (STL) for defining several templates that help define and manipulate iterators | ||
+ | *<limits> -- for testing numeric type properties | ||
+ | *<list> -- (STL) for defining a template class that implements a list container | ||
+ | *<locale> -- for defining several classes and templates that control locale-specific behavior, as in the iostreams classes | ||
+ | *<map> -- (STL) for defining template classes that implement associative containers | ||
+ | *<memory> -- (STL) for defining several templates that allocate and free storage for various container classes | ||
+ | *<numeric> -- (STL) for defining several templates that implement useful numeric functions | ||
+ | *<ostream> -- for defining the template class that performs insertions | ||
+ | *<queue> -- (STL) for defining a template class that implements a queue container | ||
+ | *<set> -- (STL) for defining template classes that implement associative containers with unique elements | ||
+ | *<sstream> -- for defining several iostreams template classes that manipulate string containers | ||
+ | *<stack> -- (STL) for defining a template class that implements a stack container | ||
+ | *<stdexcept> -- for defining several classes useful for reporting exceptions | ||
+ | *<streambuf> -- for defining template classes that buffer iostreams operations | ||
+ | *<string> -- for defining a template class that implements a string container | ||
+ | *<strstream> -- for defining several iostreams classes that manipulate in-memory character sequences | ||
+ | *<utility> -- (STL) for defining several templates of general utility | ||
+ | *<valarray> -- for defining several classes and template classes that support value-oriented arrays | ||
+ | *<vector> -- (STL) for defining a template class that implements a vector container | ||
+ | |||
+ | ==多范式== | ||
+ | 从某种观点看,C++ 实际上是将三种语言合为一体: | ||
+ | * 一个类似 [[c programming language|C]] 的语言(支持低级程序设计) | ||
+ | * 一个类似 [[Ada]] 的语言(支持抽象数据类型程序设计) | ||
+ | * 一个类似 [http://www.simula67.info/ Simula] 的语言(支持面向对象的程序设计) [https://portablesimula.github.io/github.io/doc/SimulaTextBook.pdf An Introduction to Programming in Simula] | ||
+ | 来自《C++语言的设计与演进》p164 | ||
+ | |||
+ | 此外,C++ | ||
+ | *面向对象(灵活应用virtual继承+shared_ptr可以达到java/C#的效果) | ||
+ | *模板(这里分两类,分别为type rich programming和meta programming,区别很大) | ||
+ | *函数式编程(如今有了lambda,配合<algorithm>文件,简直无敌了) | ||
+ | *过程式 | ||
+ | 此处来源:[https://www.zhihu.com/question/19794858/answer/18448868 知乎] | ||
+ | |||
+ | 另外观点: | ||
+ | C++是四类范式的组合体: | ||
+ | * 过程式/结构化 | ||
+ | * 面向对象 | ||
+ | * 代表Lambda的模板(元编程) | ||
+ | * 以及作为一个Markov Machine也具有图灵完备性的宏。 | ||
+ | |||
+ | [https://www.zhihu.com/question/19794858/answer/18449427 此外还有一个我不知道怎么归类的type rich programming。] | ||
+ | |||
+ | [https://www.zhihu.com/question/19794858/answer/16101026 C/C++总共分成四大流派]: | ||
+ | * 1.C风格流派 | ||
+ | * 2.面向对象流派 | ||
+ | * 3.模板元流派 | ||
+ | * 4.混合流派 | ||
+ | |||
+ | ==编译器== | ||
+ | *[[GCC]] | ||
+ | *[[LLVM]] | ||
+ | |||
+ | ==C++学习== | ||
+ | *[https://github.com/isocpp/CppCoreGuidelines C++ Core Guidelines] | ||
+ | *[https://github.com/Microsoft/GSL GSL: Guidelines Support Library] | ||
+ | |||
+ | C++语言中出现的 extern "C"语法 | ||
+ | extern "C" { | ||
+ | extern int getopt(int, char * const *, const char *); | ||
+ | extern char *optarg; | ||
+ | } | ||
+ | 被extern "C"修饰的变量和函数是按照C语言方式编译和连接的; | ||
+ | |||
+ | 这源于C++支持函数重载,而过程式语言C则不支持。而编译后的名字会有所不同, | ||
+ | void foo( int x, int y ); | ||
+ | c 编译后 _foo | ||
+ | c++ 编译后 _foo_int_int | ||
+ | void foo( int x, float y ) | ||
+ | c++ 编译后 _foo_int_float | ||
+ | 编译后的类似_foo_int_int这样的名字包含了函数名、函数参数数量及类型信息,C++就是靠这种机制来实现函数重载的。 | ||
+ | |||
+ | ==编码风格== | ||
+ | *[https://github.com/isocpp/CppCoreGuidelines C++ Core Guidelines] - "Official" set of C++ guidelines, reviewed by the author of C++. | ||
+ | *[http://www.chromium.org/developers/coding-style/cpp-dos-and-donts C++ Dos and Don'ts] - The Chromium Projects > For Developers > Coding Style > C++ Dos and Don'ts. | ||
+ | *[https://github.com/google/styleguide google-styleguide] - Style guides for Google-originated open-source projects. | ||
+ | *[https://google.github.io/styleguide/cppguide.html Google C++ Style Guide] | ||
+ | *[http://www.gnu.org/prep/standards/standards.html GNU Coding Standard] | ||
+ | *[https://www.kernel.org/doc/Documentation/CodingStyle Linux kernel coding style] | ||
+ | *[http://llvm.org/docs/CodingStandards.html LLVM Coding Standards] | ||
+ | |||
+ | ==Documents== | ||
+ | *[http://docs.huihoo.com/cppreference/ C/C++ Reference] | ||
+ | *[http://en.cppreference.com/w/ C++ reference Wiki] | ||
+ | *[http://docs.huihoo.com/gnu/c++-tutorial/tutorial/ Complete C++ language tutorial] | ||
+ | *[http://docs.huihoo.com/boost/ Boost C++ Libraries] | ||
+ | *[http://gnu.huihoo.org/gcc/ GCC online documentation] | ||
+ | *[http://book.huihoo.com/how-to-think-like-a-computer-scientist-cpp-version/ How To Think Like A Computer Scientist Learning with C++] | ||
+ | *[http://book.huihoo.com/data-structures-and-algorithms-with-object-oriented-design-patterns-in-c++/html/ Data Structures and Algorithms with Object-Oriented Design Patterns in C++] | ||
+ | |||
+ | ==文档== | ||
+ | *[http://docs.huihoo.com/infoq/qconshanghai/2015/C++11%e6%a0%b8%e5%bf%83%e7%89%b9%e6%80%a7%e7%ae%80%e6%9e%90.pdf C++11核心特性简析] | ||
+ | *[http://docs.huihoo.com/cpp/from-cpp-primer-learn-cpp.pdf 从《C++ Primer 第四版》入手学习 C++] | ||
+ | *[http://docs.huihoo.com/cpp/cpp-history-and-rationale.pdf C++ History and Rationale] | ||
+ | *[http://docs.huihoo.com/cpp/cpp-dtor-meets-mt.pdf 当析构函数遇到多线程 ─ C++中线程安全的对象回调] | ||
+ | *[http://docs.huihoo.com/cpp/learning-network-programming-20120213.pdf 谈一谈网络编程学习经验] | ||
+ | *[http://docs.huihoo.com/cpp/cpp-practice-20120420.pdf C++ 工程实践经验谈] | ||
+ | |||
+ | ==链接== | ||
+ | *[http://public.research.att.com/~bs/ C++之父] | ||
+ | *[http://docs.huihoo.com/gnu/CppCodingStandard.html C++ Coding Standard] | ||
+ | *[http://www.royaloo.com/ 荣耀] | ||
+ | *[http://www.informit.com/guides/guide.aspx?g=cplusplus C++ Reference Guide] | ||
+ | *[https://www.ibm.com/developerworks/cn/linux/theme/ccpp/ IBM developerWorks 中国: C/C++ 技术专题] | ||
+ | *[https://www.zhihu.com/question/19794858 怎么样才算是精通 C++?] | ||
+ | *[http://purecpp.org/ purecpp.org] | ||
+ | |||
+ | ==IDE== | ||
+ | *[[Emacs]] | ||
+ | *[[CodeLite]] | ||
+ | *[[Dev-C++]] | ||
+ | *[[Code::Blocks]] | ||
+ | *[[geany]] | ||
+ | *[[Anjuta]] | ||
+ | *[[KDevelop]] | ||
+ | *[[Qt Creator]] | ||
+ | 更多:[https://en.wikipedia.org/wiki/Category:Free_integrated_development_environments Free integrated development environments] | ||
+ | |||
+ | ==Compilers== | ||
+ | *GCC http://gcc.gnu.org/ | ||
+ | *MinGW http://www.mingw.org/ | ||
+ | *Cygwin (GNU + cygnus + Windows) http://cygwin.com/ | ||
+ | *Visual C++ Toolkit 2003 http://msdn.microsoft.com/visualc/vctoolkit2003/ | ||
+ | *Borland C++ Compiler 5.5 http://www.borland.com/products/downloads/download_cbuilder.html | ||
+ | *Borland C++BuilderX Personal 1.0 http://www.borland.com/products/downloads/download_cbuilderx.html | ||
+ | *Digital Mars C/C++ Compiler for Win32 http://www.digitalmars.com | ||
+ | *Open Watcom http://www.openwatcom.org/ | ||
+ | *Dinkum Exam (EDG C++ front end) http://dinkumware.com/exam/dinkumExam.aspx | ||
+ | *Comeau C++ Online (EDG C++ front end) http://www.comeaucomputing.com/tryitout/ | ||
+ | |||
+ | ==News Groups== | ||
+ | *comp.lang.c.moderated | ||
+ | *comp.lang.c++.moderated | ||
+ | *comp.std.c++ | ||
+ | |||
+ | ==Misc== | ||
+ | *The C Standards Committee(ISO C) http://www.open-std.org/jtc1/sc22/wg14/ | ||
+ | *The C++ Standard Committee(ISO C++) http://www.open-std.org/jtc1/sc22/wg21/ | ||
+ | *ACCU (The Association of C and C++ Users) http://www.accu.org | ||
+ | *Incompatibilities Between ISO C and ISO C++ http://david.tribble.com/text/cdiffs.htm | ||
+ | *STLFilt: An STL Error Message Decryptor for C++ http://www.bdsoft.com/tools/stlfilt.html | ||
+ | *CppUnit http://cppunit.sourceforge.net | ||
+ | *The C++ Source http://www.artima.com/cppsource/ | ||
+ | *QT http://www.trolltech.com | ||
+ | |||
+ | ==Libraries== | ||
+ | [[文件:boost-logo.png|right|Boost]] | ||
+ | *[[Boost]] http://www.boost.org | ||
+ | *[[SGI STL]] http://www.sgi.com/tech/stl | ||
+ | *[[STLport]] http://www.stlport.org | ||
+ | *RougeWave Standard C++ Library http://www.ccd.bnl.gov/bcf/cluster/pgi/pgC++_lib/stdlib.htm | ||
+ | *ACE http://www.cs.wustl.edu/~schmidt/ACE.html | ||
+ | *FC++ http://www.cc.gatech.edu/~yannis/fc++/ | ||
+ | *Blitz++ http://www.oonumerics.org/blitz | ||
+ | *Loki http://sourceforge.net/projects/loki-lib/ | ||
+ | *MTL http://www.osl.iu.edu/research/mtl/ | ||
+ | *POOMA http://www.pooma.com | ||
+ | *CGAL http://www.cgal.org/ | ||
+ | *ROOT http://root.cern.ch/root/ | ||
+ | |||
+ | ==图集== | ||
+ | <gallery> | ||
+ | image:SYCL-Single-Source-CPP-Parallel-Programming.jpeg|SYCL | ||
+ | image:CPP-Books.png|C++之父给你的C++学习路线图 | ||
+ | image:cpp-book-01.jpeg|C++程序设计语言(第1~3部分) | ||
+ | image:cpp-book-02.jpeg|C++程序设计语言(第4部分:标准库) | ||
+ | image:cpp-book-03.jpeg|C++程序设计:原理与实践(基础篇) | ||
+ | image:cpp-book-04.jpeg|C++程序设计:原理与实践(进阶篇) | ||
+ | image:cpp-book-05.jpeg|C++语言导学 | ||
+ | </gallery> | ||
+ | |||
+ | ==VC ++== | ||
+ | VC++6.0MSDN | ||
+ | 下载1 [http://download.microsoft.com/download/A/9/1/A91D6B2B-A798-47DF-9C7E-A97854B7DD18/VC.iso ISO文件] | ||
+ | 下载2 [http://ftp.sdshiyan.cn/soft/program/DN60ACHS1.rar RAR 文件] | ||
+ | 下载3 [http://ftp.sdshiyan.cn/soft/program/DN60ACHS2.rar RAR 文件] | ||
+ | |||
+ | ==链接== | ||
+ | ===Materials=== | ||
+ | *[http://www.dinkumware.com/manuals/ Dinkumware's C++ Library Reference Manual] | ||
+ | *[http://cppreference.com/ C/C++ Reference] | ||
+ | *[http://www.open-std.org/jtc1/sc22/wg21/ Standards Committee Page: JTC1/SC22/WG21 - C++] | ||
+ | *[http://www.CodePedia.com/1/CCplusplus CodePedia] | ||
+ | *[http://cmeerw.org/prog/freecpp/ A Compiler-Comparison chart] | ||
+ | |||
+ | ====Tutorials==== | ||
+ | *[http://www.cplusplus.com/doc/ C++ Language Tutorial] cplusplus.com | ||
+ | *[http://cplus.about.com/od/beginnerctutorial/l/blcplustut.htm C++ Programming Tutorial] About.com | ||
+ | *[http://www.icce.rug.nl/documents/cplusplus/ The C++ Annotations] | ||
+ | *[http://lepslair.com/tutorials/c/ Programming in C++] . | ||
+ | |||
+ | ====Electronic books==== | ||
+ | *[http://www.relisoft.com/book/index.htm Free book "C++ In Action"] by Bartosz Milewski | ||
+ | *[http://mindview.net/Books/TICPP/ThinkingInCPP2e.html Free book "Thinking in C++"] by Bruce Eckel | ||
+ | *[http://www.computer-books.us/cpp.php Computer-Books.us] Collection of online C++ books. | ||
+ | *[http://www.ibiblio.org/obp/thinkCS/cpp/english/ How To Think Like A Computer Scientist: Learning with C++] by A.B. Downey | ||
+ | |||
+ | ===Support=== | ||
+ | *[http://www.parashift.com/c%2B%2B-faq-lite/ C++ FAQ Lite by Marshall Cline] | ||
+ | * Newsgroups "[news://comp.lang.c++ comp.lang.c++]" "[news://comp.lang.c++.moderated comp.lang.c++.moderated]" "[news://comp.std.c++ comp.std.c++]" | ||
+ | *[http://cboard.cprogramming.com/forumdisplay.php?f=3 C++ Forum] at Cprogramming.com | ||
+ | *[http://www.daniweb.com/techtalkforums/forum8.html C and C++] at Daniweb | ||
+ | *[http://forums.dreamincode.net/showforum15.htm C++ Forum] at Dream.In.Code | ||
+ | |||
+ | ===Other=== | ||
+ | *http://ootips.org/ | ||
+ | *[http://www.freebyte.com/programming/cpp/ links to C++ Tools] | ||
+ | *[http://www.robertnz.net/cpp_site.html Internet sites and files of interest to C++ users], A categorised list of C++ related links. | ||
+ | *[http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml Google C++ Style Guide] | ||
− | + | ====Libraries and code repositories==== | |
+ | *[http://www.boost.org/ Boost.org] - Selection of peer-reviewed C++ libraries designed to work with the standard C++ library | ||
+ | *[http://www.codesynthesis.com/products/xsd/ XSD: XML Data Binding for C++] | ||
+ | *[http://csourcesearch.net/ csourcesearch.net] (Searchable Open Source C/C++ Code Archive) | ||
+ | *[http://www.gnu.org/software/commoncpp/ Portable foundation classes from GNU] | ||
+ | *[http://stlsoft.org/ STLSoft libraries]: Open-source, 100% header-only, C/C++ libraries of technology-specific facades and STL extensions. | ||
− | + | [[category:c++]] | |
− | + | [[category:programming language]] | |
− | + | [[category:Huihoo Foundation]] | |
− | + |
2022年8月26日 (五) 04:12的最后版本
您可以在Wikipedia上了解到此条目的英文信息 C++ Thanks, Wikipedia. |
C++
目录 |
[编辑] 简介
C++ 是世界上最流行的系统级语言
C++语言是一种应用较广的面向对象的程序设计语言,使用它可以实现面向对象的程序设计。面向对象的设计与面向过程的设计是有很大区别的,面向对象的程序设计是在面向过程的程序设计的基础上一个质的飞跃。要学会面向对象的程序设计,首先要学会一种面向对象的语言,即要学会用VC编程,就要先有C++的基础,而学习C++语言首先要认识它面向对象的特性和实现面向对象的方法。
第一个 C++ 程序
#include <iostream> int main() { std::cout << "hello, world\n"; }
[编辑] 历史
- C++ 语言设计受到了 Simula 的重要影响,Simula 一种编译式的编程语言,由奥利-约翰·达尔与克利斯登·奈加特,在1960年代于奥斯陆的挪威计算中心,开发出来了 Simula I 与 Simula 67 两代。它承继了 ALGOL 60 的基础,被认为是第一个面向对象编程的编程语言。
- A History of C++: 1979−1991
[编辑] C++标准
C++主要版本:1998, 2003, 2011, 2014, 2017, 2020
- 2020,ISO/IEC 14882:2020, C++20, 第六个C++标准
- 2017, ISO/IEC 14882:2017, C++17, 第五个C++标准
- 2014, ISO/IEC 14882:2014, C++14, 第四个C++标准
- 2011, ISO/IEC 14882:2011, C++11, 第三个C++标准
- 2003, ISO/IEC 14882:2003, C++03, 第二个C++标准
- 1998, ISO/IEC 14882:1998, C++98, 第一个C++标准
C++标准的运作方式:ISO标准委员会,SC22 WG21,是在ISO规则下运行的。奇怪的是,这些规则并非标准化的,而是随着时间的变化而变化。(译注:标准委员会的规则并不标准)。大多数国家都有活跃的C++团体并形成了自己的国家标准。这些团体举行会议,通过网络协调一致,并向ISO会议推选代表。加拿大,法国,德国,瑞士,英国和美国是出席这些会议较多的国家。丹麦,荷兰,日本,挪威,西班牙和别的一些国家则是出席人数比较少的国家。大多数通过网络召开的会议都是介于这两者之间,会议记录由标准委员会编号并存放在 WG21。
标准委员会每年召开两到三次会议,每次约一周的时间。这些会议的大部分工作就是工作划分,比如“核心“,”库“,”演化“,“并发”。根据需要,也会为了解决一些迫切的问题而召开会议,比如“概念”和“内存模型”。会议主要用来投票表决。首先,工作组举行民意投票来判断某个论点是否可以作为一个整体提案递交给标准委员会。然后,如果这个提案被接受,标准委员会将进行每人一票的投票表决。我们花费大量注意力在那些我们没有进入但是已经有很多人表现出来和国家不同意的形势--这将会导致长期的争论。最后,官方草案的投票由国家标准机构通过邮件完成。标准委员会和C标准组织以及POSIX有正式的联系,并和其他一些组织也有或多或少的联系。
标准委员会包括大约200个人,其中有大约60位会出席每年两到三次一周时间的会议。除此之外,在一些国家还有一些国家标准组织和会议。多数成员通过出席会议,邮件讨论或提交论文供标准委员会斟酌等方式贡献自己的力量。多数成员有朋友或同事提供帮助。第一天,标准委员会召集从各个国家而来的代表,并且每一次会议由6到12个国家的代表参加。最终投票由20个国家标准组织完成。
[编辑] 状态
[编辑] Library
Standard C++ library headers listed below, 13 constitute the Standard Template Library, or STL.
- <algorithm> -- (STL) for defining numerous templates that implement useful algorithms
- <bitset> -- for defining a template class that administers sets of bits
- <cassert> -- for enforcing assertions when functions execute
- <cctype> -- for classifying characters
- <cerrno> -- for testing error codes reported by library functions
- <cfloat> -- for testing floating-point type properties
- <ciso646> -- for programming in ISO 646 variant character sets
- <climits> -- for testing integer type properties
- <clocale> -- for adapting to different cultural conventions
- <cmath> -- for computing common mathematical functions
- <complex> -- for defining a template class that supports complex arithmetic
- <csetjmp> -- for executing nonlocal goto statements
- <csignal> -- for controlling various exceptional conditions
- <cstdarg> -- for accessing a varying number of arguments
- <cstddef> -- for defining several useful types and macros
- <cstdio> -- for performing input and output
- <cstdlib> -- for performing a variety of operations
- <cstring> -- for manipulating several kinds of strings
- <ctime> -- for converting between various time and date formats
- <cwchar> -- for manipulating wide streams and several kinds of strings
- <cwctype> -- for classifying wide characters
- <deque> -- (STL) for defining a template class that implements a deque container
- <exception> -- for defining several functions that control exception handling
- <fstream> -- for defining several iostreams template classes that manipulate external files
- <functional> -- (STL) for defining several templates that help construct predicates for the templates defined in <algorithm> and <numeric>
- <iomanip> -- for declaring several iostreams manipulators that take an argument
- <ios> -- for defining the template class that serves as the base for many iostreams classes
- <iosfwd> -- for declaring several iostreams template classes before they are necessarily defined
- <iostream> -- for declaring the iostreams objects that manipulate the standard streams
- <istream> -- for defining the template class that performs extractions
- <iterator> -- (STL) for defining several templates that help define and manipulate iterators
- <limits> -- for testing numeric type properties
- <list> -- (STL) for defining a template class that implements a list container
- <locale> -- for defining several classes and templates that control locale-specific behavior, as in the iostreams classes
- <map> -- (STL) for defining template classes that implement associative containers
- <memory> -- (STL) for defining several templates that allocate and free storage for various container classes
- <numeric> -- (STL) for defining several templates that implement useful numeric functions
- <ostream> -- for defining the template class that performs insertions
- <queue> -- (STL) for defining a template class that implements a queue container
- <set> -- (STL) for defining template classes that implement associative containers with unique elements
- <sstream> -- for defining several iostreams template classes that manipulate string containers
- <stack> -- (STL) for defining a template class that implements a stack container
- <stdexcept> -- for defining several classes useful for reporting exceptions
- <streambuf> -- for defining template classes that buffer iostreams operations
- <string> -- for defining a template class that implements a string container
- <strstream> -- for defining several iostreams classes that manipulate in-memory character sequences
- <utility> -- (STL) for defining several templates of general utility
- <valarray> -- for defining several classes and template classes that support value-oriented arrays
- <vector> -- (STL) for defining a template class that implements a vector container
[编辑] 多范式
从某种观点看,C++ 实际上是将三种语言合为一体:
- 一个类似 C 的语言(支持低级程序设计)
- 一个类似 Ada 的语言(支持抽象数据类型程序设计)
- 一个类似 Simula 的语言(支持面向对象的程序设计) An Introduction to Programming in Simula
来自《C++语言的设计与演进》p164
此外,C++
- 面向对象(灵活应用virtual继承+shared_ptr可以达到java/C#的效果)
- 模板(这里分两类,分别为type rich programming和meta programming,区别很大)
- 函数式编程(如今有了lambda,配合<algorithm>文件,简直无敌了)
- 过程式
此处来源:知乎
另外观点: C++是四类范式的组合体:
- 过程式/结构化
- 面向对象
- 代表Lambda的模板(元编程)
- 以及作为一个Markov Machine也具有图灵完备性的宏。
此外还有一个我不知道怎么归类的type rich programming。
- 1.C风格流派
- 2.面向对象流派
- 3.模板元流派
- 4.混合流派
[编辑] 编译器
[编辑] C++学习
C++语言中出现的 extern "C"语法
extern "C" { extern int getopt(int, char * const *, const char *); extern char *optarg; }
被extern "C"修饰的变量和函数是按照C语言方式编译和连接的;
这源于C++支持函数重载,而过程式语言C则不支持。而编译后的名字会有所不同,
void foo( int x, int y ); c 编译后 _foo c++ 编译后 _foo_int_int void foo( int x, float y ) c++ 编译后 _foo_int_float
编译后的类似_foo_int_int这样的名字包含了函数名、函数参数数量及类型信息,C++就是靠这种机制来实现函数重载的。
[编辑] 编码风格
- C++ Core Guidelines - "Official" set of C++ guidelines, reviewed by the author of C++.
- C++ Dos and Don'ts - The Chromium Projects > For Developers > Coding Style > C++ Dos and Don'ts.
- google-styleguide - Style guides for Google-originated open-source projects.
- Google C++ Style Guide
- GNU Coding Standard
- Linux kernel coding style
- LLVM Coding Standards
[编辑] Documents
- C/C++ Reference
- C++ reference Wiki
- Complete C++ language tutorial
- Boost C++ Libraries
- GCC online documentation
- How To Think Like A Computer Scientist Learning with C++
- Data Structures and Algorithms with Object-Oriented Design Patterns in C++
[编辑] 文档
- C++11核心特性简析
- 从《C++ Primer 第四版》入手学习 C++
- C++ History and Rationale
- 当析构函数遇到多线程 ─ C++中线程安全的对象回调
- 谈一谈网络编程学习经验
- C++ 工程实践经验谈
[编辑] 链接
- C++之父
- C++ Coding Standard
- 荣耀
- C++ Reference Guide
- IBM developerWorks 中国: C/C++ 技术专题
- 怎么样才算是精通 C++?
- purecpp.org
[编辑] IDE
更多:Free integrated development environments
[编辑] Compilers
- GCC http://gcc.gnu.org/
- MinGW http://www.mingw.org/
- Cygwin (GNU + cygnus + Windows) http://cygwin.com/
- Visual C++ Toolkit 2003 http://msdn.microsoft.com/visualc/vctoolkit2003/
- Borland C++ Compiler 5.5 http://www.borland.com/products/downloads/download_cbuilder.html
- Borland C++BuilderX Personal 1.0 http://www.borland.com/products/downloads/download_cbuilderx.html
- Digital Mars C/C++ Compiler for Win32 http://www.digitalmars.com
- Open Watcom http://www.openwatcom.org/
- Dinkum Exam (EDG C++ front end) http://dinkumware.com/exam/dinkumExam.aspx
- Comeau C++ Online (EDG C++ front end) http://www.comeaucomputing.com/tryitout/
[编辑] News Groups
- comp.lang.c.moderated
- comp.lang.c++.moderated
- comp.std.c++
[编辑] Misc
- The C Standards Committee(ISO C) http://www.open-std.org/jtc1/sc22/wg14/
- The C++ Standard Committee(ISO C++) http://www.open-std.org/jtc1/sc22/wg21/
- ACCU (The Association of C and C++ Users) http://www.accu.org
- Incompatibilities Between ISO C and ISO C++ http://david.tribble.com/text/cdiffs.htm
- STLFilt: An STL Error Message Decryptor for C++ http://www.bdsoft.com/tools/stlfilt.html
- CppUnit http://cppunit.sourceforge.net
- The C++ Source http://www.artima.com/cppsource/
- QT http://www.trolltech.com
[编辑] Libraries
- Boost http://www.boost.org
- SGI STL http://www.sgi.com/tech/stl
- STLport http://www.stlport.org
- RougeWave Standard C++ Library http://www.ccd.bnl.gov/bcf/cluster/pgi/pgC++_lib/stdlib.htm
- ACE http://www.cs.wustl.edu/~schmidt/ACE.html
- FC++ http://www.cc.gatech.edu/~yannis/fc++/
- Blitz++ http://www.oonumerics.org/blitz
- Loki http://sourceforge.net/projects/loki-lib/
- MTL http://www.osl.iu.edu/research/mtl/
- POOMA http://www.pooma.com
- CGAL http://www.cgal.org/
- ROOT http://root.cern.ch/root/
[编辑] 图集
[编辑] VC ++
VC++6.0MSDN
下载1 ISO文件 下载2 RAR 文件 下载3 RAR 文件
[编辑] 链接
[编辑] Materials
- Dinkumware's C++ Library Reference Manual
- C/C++ Reference
- Standards Committee Page: JTC1/SC22/WG21 - C++
- CodePedia
- A Compiler-Comparison chart
[编辑] Tutorials
- C++ Language Tutorial cplusplus.com
- C++ Programming Tutorial About.com
- The C++ Annotations
- Programming in C++ .
[编辑] Electronic books
- Free book "C++ In Action" by Bartosz Milewski
- Free book "Thinking in C++" by Bruce Eckel
- Computer-Books.us Collection of online C++ books.
- How To Think Like A Computer Scientist: Learning with C++ by A.B. Downey
[编辑] Support
- C++ FAQ Lite by Marshall Cline
- Newsgroups "comp.lang.c++" "comp.lang.c++.moderated" "comp.std.c++"
- C++ Forum at Cprogramming.com
- C and C++ at Daniweb
- C++ Forum at Dream.In.Code
[编辑] Other
- http://ootips.org/
- links to C++ Tools
- Internet sites and files of interest to C++ users, A categorised list of C++ related links.
- Google C++ Style Guide
[编辑] Libraries and code repositories
- Boost.org - Selection of peer-reviewed C++ libraries designed to work with the standard C++ library
- XSD: XML Data Binding for C++
- csourcesearch.net (Searchable Open Source C/C++ Code Archive)
- Portable foundation classes from GNU
- STLSoft libraries: Open-source, 100% header-only, C/C++ libraries of technology-specific facades and STL extensions.