Languages Features Calendar About Lists Add Language
GitHub icon



C++ is a programming language created in 1985 by Bjarne Stroustrup.

#6on PLDB 37Years Old 4.1mUsers
128Books 6Papers

Try now: Riju · Replit

C++ ( pronounced cee plus plus) is a general-purpose programming language. It has imperative, object-oriented and generic programming features, while also providing facilities for low-level memory manipulation. It was designed with a bias toward system programming and embedded, resource-constrained and large systems, with performance, efficiency and flexibility of use as its design highlights. Read more on Wikipedia...

Example code from Riju:

#include <iostream> int main() { std::cout << "Hello, world!" << std::endl; return 0; }

Example code from hello-world:

#include <iostream> int main() { std::cout << "Hello World" << std::endl; }

Example code from the Hello World Collection:

// Hello World in C++ (pre-ISO) #include <iostream.h> main() { cout << "Hello World!" << endl; return 0; }

Example code from Linguist:

#include <cstdint> namespace Gui { }

Example code from Wikipedia:

1 #include <iostream> 2 #include <vector> 3 #include <stdexcept> 4 5 int main() { 6 try { 7 std::vector<int> vec{3, 4, 3, 1}; 8 int i{}; // Throws an exception, std::out_of_range (indexing for vec is from 0-3 not 1-4) 9 } 10 // An exception handler, catches std::out_of_range, which is thrown by 11 catch (std::out_of_range &e) { 12 std::cerr << "Accessing a non-existent element: " << e.what() << '\n'; 13 } 14 // To catch any other standard library exceptions (they derive from std::exception) 15 catch (std::exception &e) { 16 std::cerr << "Exception thrown: " << e.what() << '\n'; 17 } 18 // Catch any unrecognised exceptions (i.e. those which don't derive from std::exception) 19 catch (...) { 20 std::cerr << "Some fatal error\n"; 21 } 22 }

Keywords in C++

#define #defined #elif #else #endif #error #if #ifdef #ifndef #include #line #pragma #undef alignas alignof and and_eq asm atomic_cancel atomic_commit atomic_noexcept auto bitand bitor bool break case catch char char16_t char32_t class compl concept const constexpr const_cast continue decltype default delete do double dynamic_cast else enum explicit export extern false final float for friend goto if inline int import long module mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected public register reinterpret_cast requires return short signed sizeof static static_assert static_cast struct switch synchronized template this thread_local throw transaction_safe transaction_safe_dynamic true try typedef typeid typename union unsigned using virtual void volatile wchar_t while xor xor_eq

Language features

Feature Supported Example Token
Scientific Notation
Access Modifiers
Switch Statements
While Loops
Case Sensitivity
MultiLine Comments
/* A comment
/* */
Virtual function
class Animal {
  // Intentionally not virtual:
  void Move(void) {
    std::cout << "This animal moves in some way" << std::endl;
  virtual void Eat(void) = 0;

// The class "Animal" may possess a definition for Eat if desired.
class Llama : public Animal {
  // The non virtual function Move is inherited but not overridden.
  void Eat(void) override {
    std::cout << "Llamas eat grass!" << std::endl;
Line Comments
// A comment
Vector& Vector::operator+=(const Vector& rhs)
    for (int i = 0; i < length; ++i)
        value[i] += rhs.value[i];
    return *this;
Print() Debugging
cout<<"hello world." << std::endl;
Operator Overloading
Multiple Inheritance
using namespace std;

// Variable created inside namespace
namespace first
  int val = 500;
// Global variable
int val = 100;
// Ways to do it:
namespace ns_name { declarations }
inline namespace ns_name { declarations }
namespace { declarations }
using namespace ns_name;
using ns_name::name;
namespace name = qualified-namespace ;
namespace ns_name::inline(since C++20)(optional) name { declarations } 
Function Overloading
// volume of a cube
int volume(const int s) {
 return s*s*s;
// volume of a cylinder
double volume(const double r, const int h) {
  return 3.1415926*r*r*static_cast(h);
Manual Memory Management
std::vector items;
items.push_back(5);  // Append integer value '5' to vector 'items'.
items.push_back(2);  // Append integer value '2' to vector 'items'.
items.push_back(9);  // Append integer value '9' to vector 'items'.

for (auto it = items.begin(); it != items.end(); ++it) {  // Iterate through 'items'.
  std::cout << *it;  // And print value of 'items' for current index.
// #pragma once is a non-standard but widely supported preprocessor directive designed to cause the current source file to be included only once in a single compilation.
#pragma once
struct foo
   int member;
// C/C++ program to check if a number is 
// even or not using goto statement 
using namespace std; 
// function to check even or not 
void checkEvenOrNot(int num) 
    if (num % 2 == 0) 
        goto even; // jump to even 
        goto odd; // jump to odd 
    cout << num << " is evenn"; 
    return; // return if even 
    cout << num << " is oddn"; 
// Driver program to test above function 
int main() 
    int num = 26; 
    return 0; 
"hello world"
int const one = 1;
class Foobar {
  Foobar(double r = 1.0,
         double alpha = 0.0)  // Constructor, parameters with default values.
      : x_(r * cos(alpha))    // <- Initializer list
    y_ = r * sin(alpha);  // <- Normal assignment

  double x_;
  double y_;
Foobar a,
       c(5, M_PI/4);
Bitwise Operators
Single Dispatch
Merges Whitespace
Partial Application
// bind example
#include      // std::cout
#include    // std::bind

// a function: (also works with function object: std::divides my_divide;)
double my_divide (double x, double y) {return x/y;}

struct MyPair {
  double a,b;
  double multiply() {return a*b;}

int main () {
  using namespace std::placeholders;    // adds visibility of _1, _2, _3,...

  // binding functions:
  auto fn_five = std::bind (my_divide,10,2);               // returns 10/2
  std::cout << fn_five() << '\n';                          // 5

  auto fn_half = std::bind (my_divide,_1,2);               // returns x/2
  std::cout << fn_half(10) << '\n';                        // 5

  auto fn_invert = std::bind (my_divide,_2,_1);            // returns y/x
  std::cout << fn_invert(10,2) << '\n';                    // 0.2

  auto fn_rounding = std::bind (my_divide,_1,_2);     // returns int(x/y)
  std::cout << fn_rounding(10,3) << '\n';                  // 3

  MyPair ten_two {10,2};

  // binding members:
  auto bound_member_fn = std::bind (&MyPair::multiply,_1); // returns x.multiply()
  std::cout << bound_member_fn(ten_two) << '\n';           // 20

  auto bound_member_data = std::bind (&MyPair::a,ten_two); // returns ten_two.a
  std::cout << bound_member_data() << '\n';                // 10

  return 0;
Unary Operators
int count = 2;
&count; // address
*count; // indirection
+count; // Positive
-count; // negative
~count; // one's complement
!x; // logical negation
sizeof count;
int i = 0;
int i = 0;
Booleans true false
int *p;
File Imports
Fixed Point Numbers ϴ
Garbage Collection ϴ
Magic Getters and Setters ϴ
Units of Measure ϴ
Semantic Indentation ϴ
Regular Expression Syntax Sugar ϴ

Trending C++ repos on GitHub

repo stars description
mediapipe 2824 MediaPipe is a cross-platform framework for building multimodal applied machine learning pipelines
fmt 6596 A modern formatting library
Hazel 1589 Hazel Engine
Sonoff-Tasmota 7683 "Provide ESP8266 based itead Sonoff with Web MQTT and OTA firmware using Arduino IDE or PlatformIO"
imgui 16553 Dear ImGui: Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies
SuperWeChatPC 2071 超级微信电脑客户端,支持多开、防消息撤销、语音消息备份...开放WeChatSDK
gnuradio 1798 GNU Radio
plaidml 2457 PlaidML is a framework for making deep learning work everywhere.
WeChatRobot 1468 PC版微信机器人
interview 7108 📚 C/C++ 技术面试基础知识总结,包括语言、程序库、数据结构、算法、系统、网络、链接装载库等知识及面试经验、招聘、内推等信息。
entt 2053 Gaming meets modern C++ - a fast and reliable entity-component system (ECS) and much more
videos 535 "The official distribution of olcConsoleGameEngine a tool used in javidx9's YouTube videos and projects"
dolphin 5521 "Dolphin is a GameCube / Wii emulator allowing you to play games for these two platforms on PC with improvements."
osquery 14868 "SQL powered operating system instrumentation monitoring and analytics."
Osiris 260 "Free open-source training software / cheat for Counter-Strike: Global Offensive written in modern C++. GUI powered by imgui."
carla 3098 Open-source simulator for autonomous driving research.
grpc 22945 "The C based gRPC (C++ Python Ruby Objective-C PHP C#)"
FastLED 3180 The main FastLED library (successor to FastSPI_LED). Please direct questions/requests for advice to the reddit community - - we'd like to keep issues to just tracking bugs/enhancements/tasks. *NOTE* major library work is currently on hold
Tars 7510 "Tars is a high-performance RPC framework based on name service and Tars protocol also integrated administration platform and implemented hosting-service via flexible schedule."
thrift 6723 Apache Thrift
DALI 1829 A library containing both highly optimized building blocks and an execution engine for data pre-processing in deep learning applications
leetcode 11615 LeetCode Problems' Solutions
llvm-project 1832 This is the canonical git mirror of the LLVM subversion repository. The repository does not accept github pull requests at this moment. Please submit your patches at
pytorch 31392 Tensors and Dynamic neural networks in Python with strong GPU acceleration
onnxruntime 1113 "ONNX Runtime: cross-platform high performance scoring engine for ML models"

Books about C++ from ISBNdb

title authors year publisher
ADTs, Data Structures, and Problem Solving with C++ Nyhoff 2011 PEARSON INDIA
Data Structures & Algorithm Analysis in C++ Weiss, Mark 2013 Pearson
C++ Primer (5th Edition) Lippman, Stanley and Lajoie, Josée and Moo, Barbara 2012 Addison-Wesley Professional
Data Structures with C++ Using STL Ford, William and Topp, William 2001 Pearson
Introduction to Programming with C++ (Myprogramminglab) Liang, Y. Daniel 2013 Pearson
C++ How to Program (Early Objects Version) (9th Edition) Deitel, Paul and Deitel, Harvey 2013 Pearson
C++ Programming: Program Design Including Data Structures Malik, D. S. 2014 Cengage Learning
Engineering Problem Solving with C++ (3rd Edition) Etter, Delores M. and Ingber, Jeanine A. 2011 Pearson
Problem Solving With C++ Savitch, Walter 2011 Pearson
C++ How to Program: Late Objects Version (How to Program (Deitel)) Deitel, Paul and Deitel, Harvey 2010 Pearson
C++ Programming Today Johnston, Barbara 2007 Pearson
C++ for Java Programmers Weiss, Mark 2003 Pearson
C++ for Everyone Horstmann, Cay S. 2010 Wiley
Data Structures Using C and C++ (2nd Edition) Langsam, Yedidyah and Augenstein, Moshe J. and Tenenbaum, Aaron M. 1995 Pearson
Introduction to Programming with C++ Zak, Diane 2012 Cengage Learning
Data Structures And Algorithm Analysis in C++ Weiss, Mark Allen 2006 Pearson College Div
C++ Plus Data Structures Dale, Nell 2011 Jones & Bartlett Learning
Developing Series 60 Applications: A Guide for Symbian OS C++ Developers: A Guide for Symbian OS C++ Developers Edwards, Leigh and Barker, Richard and Staff of EMCC Software Ltd. 2004 Addison-Wesley Professional
The C++ Programming Language (3rd Edition) Stroustrup, Bjarne 1997 Addison-Wesley Professional
C++ Standard Library, The: A Tutorial And Reference 2Nd Edition NICOLAI M JOSUTTIS 2012 PEARSON INDIA
Starting Out with Games & Graphics in C++ Gaddis, Tony 2012 Pearson
Problem Solving with C++ Savitch, Walter 2008 Addison Wesley
Programming And Problem Solving With C++ Dale, Nell 2009 Jones & Bartlett Learning
Introduction to C++ Programming, Brief Edition D. S. Malik 2009 Course Technology
Programming: Principles and Practice Using C++ Stroustrup, Bjarne 2008 Addison-Wesley Professional
C++ Programming: From Problem Analysis to Program Design Malik, D. S. 2008 Cengage Learning
An Introduction to Computing Using C++ and Object Technology Ford, William H. and Topp, William R. 1998 Pearson
C++ Template Metaprogramming Abrahams, David 2004 Addison-Wesley Professional
C++ Programming: Program Design Including Data Structures (MindTap Course List) Malik, D. S. 2017 Cengage Learning
C++ Programs to Accompany Programming Logic and Design Smith, Jo Ann 2012 Course Technology
C++ for Everyone Horstmann, Cay S. 2011 Wiley
C++ Programming: From Problem Analysis to Program Design (Introduction to Programming) Malik, D. S. 2010 Cengage Learning
Understanding Programming: An Introduction Using C++ Cannon, Scott R. 2000 Course Technology
Absolute C++ (4th Edition) Savitch, Walter 2009 Pearson
C++ from the Ground Up: Learn C++ from the Master Schildt, Herbert 1994 Mcgraw-Hill Osborne Media
Hands-On Embedded Programming with C++17: Create versatile and robust embedded solutions for MCUs and RTOSes with modern C++ Posch, Maya 2019 Packt Publishing
C++ How to Program plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition) Deitel, Paul and Deitel, Harvey 2013 Pearson
C++ GUI Programming with Qt 4 (2nd Edition) (Prentice Hall Open Source Software Development Series) Blanchette, Jasmin and Summerfield, Mark 2008 Prentice Hall
C++ from the Ground Up, Third Edition Schildt, Herbert 2003 McGraw-Hill Education
Object-Oriented Programming Using C++ (Introduction to Programming) Farrell, Joyce 2008 Cengage Learning
Problem Solving with C++ Plus MyLab Programming with Pearson eText -- Access Card Package Savitch, Walter 2017 Pearson
C++ How to Program (6th Edition) Deitel, Paul J. 2007 Prentice Hall
Algorithms in C++ Sedgewick, Robert 1992 Addison-Wesley Pub (Sd)
Professional C++ Solter, Nicholas A. and Kleper, Scott J. 2005 Wrox
Parallel Scientific Computing in C++ and MPI: A Seamless Approach to Parallel Algorithms and their Implementation Karniadakis, George Em 2003 Cambridge University Press
C++ GUI Programming with Qt 4 Blanchette, Jasmin and Summerfield, Mark 2006 Prentice Hall PTR
C++ Primer Lippman, Stanley B. and Lajoie, Josee and Moo, Barbara E. 2005 Addison-Wesley Professional
Enough Rope to Shoot Yourself in the Foot: Rules for C and C++ Programming (Unix/C) Holub, Allen I. 1995 Computing McGraw-Hill
Assembly Language and Computer Architecture Using C++ and Java™ Dos Reis, Anthony J. 2004 Course Technology
Advanced CORBA® Programming with C++ Henning, Michi and Vinoski, Steve 1999 Addison-Wesley Professional
Introduction to Programming with C++ (2nd Edition) Liang, Y. Daniel 2009 Pearson
Programming in C++ Dewhurst, Stephen 1989 Pearson Ptr
C++ Programming in easy steps McGrath, Mike 2011 In Easy Steps Limited
C++ Gotchas: Avoiding Common Problems in Coding and Design Dewhurst, Stephen C. 2002 Addison-Wesley Professional
MyLab Programming with Pearson eText -- Access Card -- for Starting Out with C++ from Control Structures to Objects (My Programming Lab) Gaddis, Tony 2017 Pearson
Object Oriented Programming In C++ Johnsonbaugh, Richard and Kalin, Martin 1994 Macmillan Coll Div
Ivor Horton's Beginning Visual C++ 2010 Horton, Ivor 2010 Wrox
C++ Programming And Fundamental Concepts Anderson Jr., Arthur E. 2008 Pearson
C++ All-In-One Desk Reference For Dummies Mueller, John Paul and Cogswell, Jeff 2009 For Dummies
Inside the C++ Object Model Lippman, Stanley B. 1996 Addison-Wesley Professional
Boost.Asio C++ Network Programming Torjo, John 2013 Packt Publishing
C++ Network Programming, Volume 2: Systematic Reuse with ACE and Frameworks Debbie Lafferty and Schmidt, Douglas and Huston, Stephen 2002 Addison-Wesley Professional
Essential C++ Lippman, Stanley B. 1999 Addison-Wesley Professional
Beginning C++ Game Programming Horton, John 2016 Packt Publishing
An Introduction to C++ and Numerical Methods Ortega, James M. and Grimshaw, Andrew S. 1998 Oxford University Press
Mylab Programming with Pearson Etext -- Access Card -- For Problem Solving with C++ Savitch, Walter 2014 Pearson
The Waite Group's Object-Oriented Programming in C++ Lafore, Robert and Waite Group 1998 Sams
Microsoft Visual C++ Windows Applications by Example: Code and explanation for real-world MFC C++ Applications Stefan Björnander 2008 Packt Publishing
C++ How to Program (4th Edition) Deitel, Harvey M. and Deitel, Paul J. 2002 Prentice Hall
C++ For C Programmers, Third Edition (3rd Edition) Pohl, Ira 1998 Addison-Wesley Professional
Numerical Methods in Finance with C++ (Mastering Mathematical Finance) Capinski, Maciej J. 2012 Cambridge University Press
Object-Oriented Programming in C++ Josuttis, Nicolai M. 2002 Wiley
Beginning C++ Through Game Programming, Second Edition Dawson, Michael 2006 Cengage Learning PTR
C++ Programming Ullman, Larry E. and Signer, Andreas 2005 Peachpit Pr
Advanced Metaprogramming in Classic C++ Di Gennaro, Davide 2015 Apress
C++ Primer Plus (Mitchell Waite Signature Series) Prata, Stephen 1998 Waite Group Pr
Expert C++ Programming: Leveraging the power of modern C++ to build scalable modular applications Swaminathan, Jeganathan and Posch, Maya and Galowicz, Jacek 2018 Packt Publishing
C++ The Core Language: A Foundation for C Programmers (Nutshell Handbooks) Brown, Doug and Satir, Gregory 1995 O'Reilly & Associates
Learn Microsoft Visual C++ 6.0 Now Sphar, Chuck 1999 Microsoft Press
Mylab Programming with Pearson Etext -- Access Code Card -- For Absolute C++ Savitch, Walter and Mock, Kenrick 2015 Pearson
Programming With Class: Introduction To Computer Science With C++ Kamin, Samuel N. and Reingold, Edward M. 1995 McGraw-Hill College
C++ Common Knowledge: Essential Intermediate Programming: Essential Intermediate Programming Dewhurst, Stephen 2005 Addison-Wesley Professional
C++ Standard Library Practical Tips (Programming Series) Reese, Greg 2005 Charles River Media
Sams Teach Yourself C++ in 21 Days (Sams Teach 21 Days) Liberty, Jesse 2001 Sams
Microsoft Mastering: MFC Development Using Microsoft Visual C++ 6.0 (DV-DLT Mastering) Microsoft Press 2000 Microsoft Press
C++ Network Programming, Volume I: Mastering Complexity with ACE and Patterns: Mastering Complexity with ACE and Patterns Schmidt, Douglas and Huston, Stephen 2001 Addison-Wesley Professional
Functional Programming in C++: How to improve your C++ programs using functional techniques Cukic, Ivan 2018 Manning Publications
Hackish C++ Games & Demos Michael Flenov 2006 A-list Publishing
Using Motif With C++ (sigs: Advances In Object Technology) Daniel J. Bernstein 1998 Sigs
C++ Program Design Davidson 2001 Irwin Professional Publishing
C++ primer Lippman, Stanley B 1989 Addison-Wesley
Programming and Problem Solving With C++ Dale, Nell B. and Weems, Chip and Headington, Mark and Dale, Nell 1996 Jones & Bartlett Pub
C++ Timesaving Techniques For Dummies Telles, Matthew 2005 For Dummies
Unix System Programming Using C++ Chan, Terrence 2021 Prentice Hall of India
C++ by Example (Programming Series) Perry, Greg M. 1992 Que Pub
Schaum's Outlines - Programming With C++ Hubbard, John R. and Hubbard, John R. 1996 Mcgraw-Hill
Programming for Graphics Files: In C and C++ Levine, John R. and Levine, John 1994 Wiley
Modern C++ for Absolute Beginners: A Friendly Introduction to C++ Programming Language and C++11 to C++20 Standards Dmitrović, Slobodan 2020 Apress
C++ Plus Data Structures Dale, Nell 2003 Jones And Bartlett Publishers
C++ Windows Programming Bjornander, Stefan 2016 Packt Publishing
An Introduction to Programming With C++ (Available Titles Skills Assessment Manager (SAM) - Office 2010) Zak, Diane 2007 Course Technology
Introduction to C++ Programming and Graphics Pozrikidis, Constantine 2007 Springer
Windows Animation Programming With C++ Young, Michael J. 1994 Morgan Kaufmann Pub
Problem Solving, Abstraction & Design Using C++ (5th Edition) Friedman, Frank L. and Koffman, Elliot B. 2006 Addison Wesley
Object-Oriented Programming with C++ (Oxford Higher Education) Sahay, Sourav 2006 Oxford University Press
C++ Programming Language, The Bjarne, Stroustrup 2013 Addison-Wesley Professional
C++ Programming with Design Patterns Revealed Muldner, Tomasz 2001 Pearson
Speech Recognition: Theory and C++ Implementation Becchetti, Claudio and Ricotti, Lucio Prina 1999 Wiley
Schaum's Easy Outline: Programming with C++ Hubbard, John R. 1999 McGraw-Hill
C++ and Object Oriented Programming Irvine, Kip R. 1996 Prentice Hall
Object-Oriented Programming in C++ (2nd Edition) Johnsonbaugh, Richard and Kalin, Martin 1999 Pearson
Practical C++ Financial Programming Oliveira, Carlos 2015 Apress
Ivor Horton's Beginning Visual C++ 2012 Horton, Ivor 2012 Wrox
Financial Instrument Pricing Using C++ Duffy, Daniel J. 2004 Wiley
Sams Teach Yourself C++ in 21 Days, Third Edition Liberty, Jesse 1999 Sams
Program Development and Design Using C++ Bronson, Gary J. 2005 Course Technology
A Jump Start Course In C++ Programming James W. Cooper and Richard B. Lam 1995 Wiley-interscience
Borland C++ Power Programming/Book and Disk Walnum, Clayton 1993 Que Pub
Practical C++ McGregor, Robert W. 1999 Que Pub
C++ Gui Programming With Qt 4 Blanchette, Jasmin. Prentice Hall In Association With Trolltech Press
Starting Out With C++: Brief Version Update, Visual C++ .net (4th Edition) Tony Gaddis and Barret Krupnow 2005 Addison Wesley
Object-oriented Programming with C++ E Balagurusamy 1997 TBS
C++ Programming In Easy Steps McGrath, Mike 2008 In Easy Steps Limited
Stl Tutorial & Reference Guide: C++ Programming With the Standard Template Library (Addison-Wesley Professional Computing Series) Musser, David R. and Saini, Atul 1996 Addison-Wesley
Boost.Asio C++ Network Programming Cookbook: Over 25 hands-on recipes to create robust and highly-effi cient cross-platform distributed applications with the Boost.Asio library Radchuk, Dmytro 2016 Packt Publishing
Starting Out With The C++ (2nd Brief Edition) Tony Gaddis 2000 Scott Jones
Data Structures Through C++: Experience Data Structures C++ through animations Kanetkar, Yashavant 2019 BPB Publications

Publications about C++ from Semantic Scholar

title authors year citations influentialCitations
C++ Programming Language B. Stroustrup 1986 7014 230
TOPAS and TOPAS-Academic: an optimization program integrating computer algebra and crystallographic objects written in C++ A. Coelho 2018 627 27
Advanced C++ Programming Styles and Idioms J. Coplien 1991 468 14
Introduction to the GiNaC Framework for Symbolic Computation within the C++ Programming Language Christian Bauer and A. Frink and R. Kreckel 2000 389 39
Supporting Students in C++ Programming Courses with Automatic Program Style Assessment Kirsti Ala-Mutka and Toni Uimonen and Hannu-Matti Järvinen 2004 84 6
An Overview of the C++ Programming Language B. Stroustrup 1999 24 3

Article source

PLDB - Build the next great programming language · v2022 · Docs · Acknowledgements · Email · GitHub