Home * Programming * Languages * C++

C++ is a pragmatical, object oriented general-purpose programming language, initially an extension of C and designed and implemented in 1979 by Bjarne Stroustrup from the 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.

C Extensions

References


Exception Handling


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 function have an implicit parameter called "this", a pointer to this structure, allocated either inside the data segment as static or global, via "new" (malloc) on the heap or as automatic object (variable) on the stack.


Data Definition

Member Functions


Modifiers

Public

Protected

Private

Static


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


Function overloading


Operator overloading


Late binding


Abstract Classes


Pure Abstract Classes


Multiple Inheritance


Templates


Class Design of a Chess Engine

main article Class Design of a Chess Engine

C++ Compiler


Libraries


See also


C++ Publications

1985 ...

1990 ...

1995 ...

2000 ...

2005 ...

2010 ...


Andrew Koenig at Dr Dobbs

  1. Introducing C++ Order Relations, January 18, 2013
  2. If C++ Objects Are Unrelated, Are They Equal?, January 24, 2013
  3. A Strategy for Defining Order Relations, February 01, 2013
  4. How Dictionaries Work, February 06, 2013
  5. Concrete Examples of Orderings, February 15, 2013
  6. Comparison and Inheritance, February 22, 2013
  7. It's Hard To Compare Floating-Point Numbers, March 01, 2013
  8. Comparing an Integer With a Floating-Point Number, Part 1: Strategy, March 08, 2013
  9. Comparing an Integer with a Floating-Point Number, Part 2: Tactics, March 15, 2013
  10. If Order Relations are Such a Pain, Why Bother?, March 22, 2013
  11. Is Optimization Immoral?, March 28, 2013
  12. Optimization Versus Flexibility — An Example, April 04, 2013
  13. Optimizing a Program Means Making It Run Faster, Right?, April 10, 2013
  14. Sometimes Optimizations Cancel Each Other, April 17, 2013
  15. Some Optimizations Are No-Brainers, April 26, 2013
  16. Sometimes, Making a Program Clearer Makes It Faster, May 02, 2013
  17. Some Subtleties of Aliasing, May 09, 2013
  18. Aliasing Is Particularly Troublesome With Vector Elements, May 17, 2013
  19. The Hazards of Remembering Positions in Vectors, May 24, 2013
  20. Copying Container Elements From The C++ Library: It's Trickier Than It Looks, May 30, 2013
  21. Moving Is Not Copying, June 06, 2013
  22. When Is It Safe to Move an Object Instead of Copying It?, June 12, 2013
  23. More Thoughts About Moving Objects Safely, June 21, 2013
  24. Moving and Rvalue References, June 27, 2013
  25. Moving an Object Does Not Destroy The Original, July 04, 2013
  26. How the C++ Compiler Decides to Move Objects, July 10, 2013
  27. Sometimes You Must Violate an Abstraction to Maintain It, July 17, 2013
  28. Is Moving Objects Worth the Hassle?, July 26, 2013
  29. Why Would You Ever Pass a Container By Value?, July 31, 2013
  30. Some Optimizations Are More Important Than Others, August 08, 2013
  31. An Important Move Optimization Is Nearly Invisible, August 15, 2013
  32. Moving Data and Address Arithmetic, August 21, 2013
  33. Addresses and Nodes: Two Ways To Get Around, August 29, 2013
  34. Theory Versus Practice: The Great Divide in Programming Languages, September 06, 2013
  35. Programming Without Variables, September 12, 2013
  36. Containers That Never Change, September 19, 2013
  37. What Does It Mean To Change An Object?, September 26, 2013
  38. A Simple, Immutable, Node-Based Data Structure, October 02, 2013
  39. Introduction to Programming with Lists, October 09, 2013
  40. Reversing an Immutable List, October 17, 2013
  41. How Do You Decide On Intermediate States?, October 23, 2013
  42. Sorting An Immutable List, October 31, 2013
  43. Practical Advantages of Immutable Values, November 07, 2013
  44. When Is An Optimization More Than Just An Optimization?, November 14, 2013
  45. Abstraction and Performance Bugs, November 21, 2013
  46. Performance Bugs Can Be Hard to Detect, November 27, 2013
  47. Performance Bugs: Not Just Hard To Detect, But Hard To Define, December 05, 2013
  48. How Can One Test a Program's Average Performance? December 12, 2013
  49. Testing Behavior, Not Just Results, December 19, 2013
  50. Not All Bugs Are Random, December 27, 2013
  51. Testing Is Not Verification and Vice Versa, January 02, 2014
  52. Social Processes and the Design of Programming Languages, January 08, 2014
  53. Why Language Designers Tolerate Undefined Behavior, January 16, 2014
  54. Even Simple Floating-Point Output Is Complicated, January 23, 2014
  55. Why Is Exact Floating-Point Output So Hard? January 30, 2014
  56. Floating-Point Input and Output Are Not Symmetric, February 06, 2014

Forum Posts

1997 ...

2000 ...

2005 ...

2010 ...

2012 ...

2014 ...


External Links


References

  1. ^ Keith E. Gorlen, Sanford M. Orlow, Perry S. Plexico (1990). Data abstraction and object-oriented programming in C++. Wiley
  2. ^ Books by Bjarne Stroustrup
  3. ^ NIH Class Library — Software Preservation Group, The Computer History Museum
  4. ^ Information on the C++11 Memory Model by Scott Meyers, April 24, 2012
  5. ^ Re: A note for C programmers by Rein Halbersma, CCC, November 28, 2013
  6. ^ Search Degredation w/ C++ by Chris Jason Richards, rgcc, June 12, 1997, post 4 and 6 by Amir Ban
  7. ^ Nice talk by Bjarne Stroustrup on C++ 11 programming style by Rémi Coulom, CCC, September 09, 2012

Up one Level