Cpp

Home * Programming * Languages * C++

C++, a pragmatical, object oriented, general-purpose programming language, initially an extension of C and designed and implemented in 1979 by Bjarne Stroustrup from Bell Laboratories. C++ is pragmatical because one may write in "usual" C-style, using the C standard library (printf, strcpy, ...), except perhaps using C++ comments and references up and then (instead of pointer). On the other hand C++ allows to design classes and interfaces (pure virtual classes) in a more object oriented manner. There are lots of free and commercial class libraries for arithmetics, database related stuff, portable and proprietary window management and whatever else. Many chess engines are written in C++, varying from using pure C-style, up to extensive use of object oriented stuff and templates as well as C++11 or C++17 features.

=C Extensions=

Exception Handling

 * C++ Programming/Exception Handling from Wikibooks
 * Exceptions - C++ Reference
 * exception - C++ Reference

=Classes= Classes as declaration for objects are more or less C-Structures. None static functions may be declared inside the scope of a class. Those functions, called member functions, have an implicit parameter called "this", a pointer to this structure, allocated either inside the data segment or bss as static or global, via "new" (malloc) on the heap or as automatic object (variable) on the stack.


 * C++ classes from Wikipedia

Data Definition

 * Basic declaration and member variables from Wikipedia

Member Functions

 * Member functions from Wikipedia

Modifiers

 * Access modifiers from Wikipedia
 * Static (keyword) from Wikipedia
 * Class variable from Wikipedia
 * Static methods from Wikipedia

Pointer to Member Functions
For instance an array of member function pointers of a class CNode, which is indexed by arbitrary pieces code - as switch-case replacement via indirect call/jump. The special atomic C++ operator ' ->* ' is used to call the indexed member-functions: class CNode { U64 AssertAttack (EnumSquare sq) const; U64 wPawnAttacks (EnumSquare sq) const; U64 bPawnAttacks (EnumSquare sq) const; U64 knightAttacks(EnumSquare sq) const; U64 kingAttacks (EnumSquare sq) const; U64 bishopAttacks(EnumSquare sq) const; U64 rookAttacks (EnumSquare sq) const; U64 queenAttacks (EnumSquare sq) const; ... typedef U64 (CNode::*AttackPtrType)(EnumSquare sq) const; static AttackPtrType m_scPieceAtta[14]; ...

U64 getAttack(EnumSquare sq, EnumPiece piece) const {return (this->*m_scPieceAtta[piece])(sq);} };

CNode::AttackPtrType CNode::m_scPieceAtta[14] = { AssertAttack, AssertAttack, wPawnAttacks, bPawnAttacks , bishopAttacks, bishopAttacks, knightAttacks, knightAttacks, rookAttacks, rookAttacks, kingAttacks, kingAttacks, queenAttacks, queenAttacks };

Inheritance

 * Inheritance (object-oriented programming) from Wikipedia
 * Inheritance from Wikibooks
 * C++/Classes and Inheritance - Wikiversity

Function Overloading

 * Function overloading from Wikipedia

Operator Overloading

 * Operator overloading from Wikipedia
 * Operator Overloading from Wikibooks

Late Binding

 * Late binding from Wikipedia
 * Virtual method table from Wikipedia
 * Virtual function from Wikipedia

Abstract Classes

 * Abstract Classes from Wikibooks

Pure Abstract Classes

 * Pure Abstract Classes from Wikibooks

Multiple Inheritance
=Templates=
 * Multiple inheritance from Wikipedia

=Anonymous Functions=
 * Anonymous functions (Blocks) from Wikipedia
 * Anonymous functions (Lambda expressions) from Wikipedia

=Smart Pointer=
 * Smart pointer from Wikipedia
 * auto_ptr from Wikipedia (C++11 deprecated)
 * unique_ptr from Wikipedia
 * shared_ptr from Wikipedia

=Class Design of a Chess Engine= main article Class Design of a Chess Engine =C++ Compiler= =Libraries=
 * List of C/C++ compilers from Wikipeadia
 * GCC
 * LLVM from Wikipeadia
 * Clang from Wikipeadia
 * Intel C++ Compiler from Wikipeadia
 * Visual C++ from Wikipeadia
 * Compiler Explorer by Matt Godbolt
 * Standard Template Library from Wikipeadia
 * STL Containers - C++ Reference
 * C++ Libraries — Software Preservation Group, The Computer History Museum
 * NIH Class Library — Software Preservation Group, The Computer History Museum


 * Qt (software) from Wikipedia
 * Loki (C++) from Wikipedia by Andrei Alexandrescu as part of his book Modern C++ Design.
 * BITSCAN, a C++ library for bitstrings by Pablo San Segundo
 * Boost (C++ libraries) from Wikipedia
 * The Better String Library by Paul Hsieh
 * log4cplus / Wiki / Home
 * Senjo C++ UCI Adapter by Shawn Chidester » Clubfoot, UCI

=See also=
 * De Bruijn Sequence Generator
 * Generic Programming
 * SSE2 - SSE2-Wrapper in C++

=C++ Publications=

1985 ...

 * Bjarne Stroustrup (1985, 1991, 1997, 2000). The C++ Programming Language. Addison-Wesley
 * Keith E. Gorlen (1987). An Object-Oriented Class Library for C++ Programs. C++ Workshop 1987
 * Bjarne Stroustrup, Andrew Koenig (1989). C++: as close as possible to C -- but no closer. C++ Report, Vol. 1, no. 7

1990 ...

 * Andrew Koenig, Bjarne Stroustrup (1990). Exception Handling for C++. Proc USENIX C++ Conference 1990, Also, Journal of Object Oriented Programming, Vol. 3, No. 2
 * Keith E. Gorlen, et al. (1990). Data abstraction and object-oriented programming in C++. Wiley
 * Andrew Koenig, Thomas A. Cargill, Keith E. Gorlen, Robert B. Murray, Michael Vilot (1991). How Useful is Multiple Inheritance in C++? C++ Conference 1991
 * Andrew Koenig (1992). Space-Efficient Trees in C++. C++ Conference 1992
 * Scott Meyers (1992,2005). Effective C++: 50 Specific Ways to Improve Your Programs and Designs. Addison-Wesley
 * Andrew Koenig (1994). Templates and Generic Algorithms. Journal of Object-Oriented Programming, Vol. 7 No. 3
 * Andrew Koenig (1994). Generic Iterators. Journal of Object-Oriented Programming, Vol. 7, No. 5
 * Bjarne Stroustrup, Andrew Koenig, Barbara Moo (1994). The C++ Programming Language. Encyclopedia of Software Engineering, Wiley

1995 ...

 * Andrew Koenig, Bjarne Stroustrup (1995). Foundations for Native C++ Styles. Software Practice and Experience, Vol 25, special issue S4
 * Patrick Winston (1995). On To C++. Addison Wesley
 * Greg Wilson, Paul Lu (eds.) (1996). Parallel Programming Using C++. MIT Press
 * Leen Ammeraal (1996). Algorithms and Data Structures in C++. John Wiley
 * Andrew Koenig, Barbara Moo (1997). Ruminations on C++. Addison-Wesley
 * Leen Ammeraal (1997). STL for C++ Programmers. ISBN 0-471-97181-2, Chichester: John Wiley

2000 ...

 * Andrew Koenig, Barbara Moo (2000). Accelerated C++. Addison-Wesley
 * Leen Ammeraal (2000). C++ for Programmers. ISBN 0-471-60697-9, Chichester: John Wiley
 * Bjarne Stroustrup, Andrew Koenig, Barbara Moo (2001). The C++ Programming Language. Encyclopedia of Software Engineering. Wiley
 * Andrei Alexandrescu (2001). Modern C++ Design: Generic Programming and Design Patterns Applied.
 * Robert L. Akers, Ira Baxter, Michael Mehlich (2004). Invited application paper: re-engineering C++ components via automatic program transformation. PEPM 2004, pdf

2005 ...

 * Robert L. Akers, Ira Baxter, Michael Mehlich, Brian J. Ellis, Kenn R. Luecke (2005). Reengineering C++ Component Models via Automatic Program Transformation. WCRE 2005
 * Robert L. Akers, Ira Baxter, Michael Mehlich, Brian J. Ellis, Kenn R. Luecke (2007). Case study: Re-engineering C++ component models via automatic program transformation. Information & Software Technology, Vol. 49, No. 3
 * Bjarne Stroustrup (2008, 2014). Programming -- Principles and Practice Using C++. Addison-Wesley

2010 ...

 * Robert C. Seacord (2010). Dangerous Optimizations and the Loss of Causality. CS 15-392, Carnegie Mellon University, slides as pdf
 * Anthony Williams (2012). C++ Concurrency in Action: Practical Multithreading.
 * Xi Wang, Haogang Chen, Alvin Cheung, Zhihao Jia, Nickolai Zeldovich, M. Frans Kaashoek (2012). Undefined Behavior: What Happened to My Code? pdf
 * Will Dietz, Peng Li, John Regehr, Vikram Adve (2012). Understanding Integer Overflow in C/C++. pdf

=Andrew Koenig at Dr Dobbs=

=Forum Posts=

1997 ...

 * Search Degredation w/ C++ by Chris Jason Richards, rgcc, June 12, 1997
 * Re: Search Degredation w/ C++ by Amir Ban, rgcc, June 17, 1997


 * Question to Amir Ban by Bas Hamstra, CCC, November 05, 1997
 * object oriented chess programming by James Long, rgcc, December 31, 1997
 * Re: object oriented chess programming by Dave Fotland, rgcc, January 06, 1998


 * C or C++ for chess programming: speed by Marc-Philippe Huget, CCC, October 20, 1999

2000 ...

 * C++ Programming Q: are const and define efficiency the same by Federico Corigliano, CCC, January 16, 2004
 * Kiwi for Win98 and input-reading stuff by Alessandro Scotti, CCC, September 29, 2004 » Kiwi, Windows, Thread

2005 ...

 * Find The Bug - C / C++ by David Rasmussen, bytes.com, July 22, 2005 » Chezzz
 * forcing compilers to inline (or to not inline) by Wylie Garvin, CCC, May 04, 2008

2010 ...

 * c or c++ ? by ethan ara, CCC, July 10, 2011
 * C++ templates question by José C. Martínez Galán, CCC, January 18, 2012
 * C++11 for chess engines by Marco Costalba, CCC, September 03, 2012
 * Has GCC caught up with Intel with respect to performance? by Don Dailey, CCC, October 07, 2012
 * Need Help Getting GCC Working?!? by Steve Maughan, CCC, April 23, 2013
 * [ub Objectives and tasks for SG12] by Gabriel Dos Reis, Open Standards, The ub Archives, May 29, 2013
 * C++ Question by Ted Wong, CCC, July 30, 2013 » Thread
 * C++11 threads seem to get shafted for cycles by User923005, OpenChess Forum, March 18, 2014 » Parallel Search, Senpai, Thread
 * c++11 std::atomic and memory_order_relaxed by Kevin Hearn, CCC, April 01, 2014 » Memory
 * C++ puzzle by Marco Costalba, CCC, April 12, 2014
 * std::vector<> considered harmful by Folkert van Heusden, CCC, September 25, 2014 » Move List, Array

2015 ...

 * Polling standard input from C++ by Steven Edwards, CCC, May 10, 2015
 * BMI2 intrinsics in gcc by Álvaro Begué, CCC, May 14, 2017 » BMI2
 * Advantages of C++11 for Chess? by Steve Maughan, CCC, October 23, 2017
 * Wouldn't it be nice if C++ GPU by Chris Whittington, CCC, April 25, 2019 » GPU
 * Re: Pawn move generation in bitboards by Álvaro Begué, CCC, December 05, 2019 » Bitboards

2020 ...

 * C++20 standard bit operations by Jon Dart, CCC, November 15, 2020 » General Setwise Operations, Population Count, BitScan

=External Links=
 * C++ from Wikipedia
 * C++03 from Wikipedia
 * C++11 from Wikipedia
 * C++14 from Wikipedia
 * C++17 from Wikipedia
 * C++20 from Wikipedia
 * C++ Programming from Wikibooks
 * More C++ Idioms - Wikibooks
 * C++ - Wikiversity
 * cplusplus.com - The C++ Resources Network
 * C++ Notes by Fred Swartz
 * C++ Historical Sources Archive — Software Preservation Group, The Computer History Museum
 * Agner Fog's manuals
 * Calling conventions for different C++ compilers and operating systems (pdf) by Agner Fog


 * C++ Optimization Strategies and Techniques by Pete Isensee
 * C++ Frequently Questioned Answers by Yossi Kreinin
 * comp.lang.c++ The object-oriented C++ language
 * Bjarne Stroustrup - The Essence of C++, YouTube Video

=References= Up one Level