User Tools

Site Tools


programming:cpp

This is an old revision of the document!


C++ Programming

C++ is a language based on CIf you want C programming, see: C Programming. C++ is a much more complex language than C. C++ is still highly portable, but not as much as C. C++ has the kitchen sink.

Editors

Technically you could write code in any text editor, but some are better than others. At minimum, you'll want to use an editor that supports syntax highlighting which will help you read the code and identify syntax errors easier.

You might also want an editor that has a built-in debugger, terminal, and version control tools. When an editor starts to incorporate these kinds of features, it becomes an integrated development environment (IDE) rather than a simple text editor.

  • vim
  • emacs
  • gedit
  • Geany
  • Visual Studio Code
  • Visual Studio
  • XCode
  • Qt Creator
  • Code::Blocks
  • Eclipse
  • Netbeans
  • CLion

Compilers

  • g++ (On Windows with MSYS2)
  • clang
  • TurboC++ (DOS)

Debugging

Methods of debugging

  • Rubber duck
  • Print statements
  • breakpoint debugging

Debuggers

  • gdb

Build tools

  • Make
  • CMake
  • Rake
  • Visual Studio
  • XCode
  • Eclipse

Code examples

Hello world

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

Command-line arguments

Environment variables

User input

Formatting output

Using tabs, using ASCII borders, formatting hex/binary/money/decimal points

programming/cpp.1618597373.txt.gz · Last modified: 2021/04/16 18:22 by nanodano