C++

From MUCSA Wiki

Jump to: navigation, search

C++ is a general-purpose programming language. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. It is a statically typed, free-form, multi-paradigm, compiled language where compilation creates machine code for the target machine hardware, supports procedural programming, data abstraction, object-oriented programming, and generic programming.

~ Wikipedia

There will soon be a new C++ standard, currently known as C++0x.

Hello world in C++:


   #include <iostream>
   int main( int argc, char** argv )
   {
       std::cout << "Hello world\n";
       return 0;
   }

A cute example of template metaprogamming in C++ (from the book "C++ Template Metaprogramming"):


   template< unsigned n, bool done = ( n < 2 ) >
       struct fibonacci
   {
       static const unsigned value =
           fibonacci< n - 1 >::value + fibonacci< n - 2 >::value;
   };
   template< unsigned n >
       struct fibonacci< n, true >
   {
       static const unsigned value = n;
   };
   unsigned i = fibonacci< 3 >::value;