wiki:cypress/Programming/CppExamples

Version 1 (modified by cmaggio, 7 years ago) (diff)

migrated content from ccs wiki

C++ codes

Hello World

//hello.cpp: display a message on the screen 
#include <iostream>
 
int main()
{
   std::cout << "Hello, C++ world!\n";
   return 0;
}
  • Text after are comments.
  • can use C style comments.
  • can use C functions.
  • #include <iostream> to load the header file.
  • There are many header files in the standard C++ library.[1]
  • Program always begins with main() function.
  • main() returns a integer.

Compile with GNU C++

g++ hello.cpp

Compile with Intel C++

icpc hello.cpp

Links for tutorial

Examples of Job Script

See Examples

Parallel C++

  • OpenMP examples in C++
  • MPI examples in C++

Useful Libraries for Scientific Computing

deal.II - A Finite Element Differential Equations Analysis Library, tutorial