Questions about this topic? Sign up to ask in the talk tab.

Difference between revisions of "CPP"

From NetSec
Jump to: navigation, search
(Created page with "C++ is a low-level programming language that is an enhancement of C.")
 
Line 1: Line 1:
C++ is a low-level programming language that is an enhancement of [[C]].
+
C++ is a compiled low-level programming language. It is an enhancement of the language [[C]].
 +
<i>The name 'C++' comes from the increment operator in C, which is "++" therefore C++</i>
 +
 
 +
Because C++ is a compiled language, you will need a compiler to compile your code.
 +
Most Linux distributions come with the proper tools such as gcc, and gdb installed. If you do not have these installed, you can install through your respective package manager.
 +
  Debian/Ubuntu:  apt get build-essential
 +
 
 +
  Arch Linux:      pacman -S base-devel
 +
 
 +
=Hello World=
 +
Here is a quick example of a "Hello World" application in C++, and how to compile it.
 +
==The code==
 +
{{code|text=
 +
<source lang="cpp">
 +
#include <iostream> //preprocessor directive, tells the compiler to 'include' the file "iostream"
 +
//This is a comment by the way.
 +
/*
 +
so is this.
 +
except
 +
it's
 +
a multi-line
 +
comment.
 +
*/
 +
//The compiler ignores comments.
 +
 
 +
//here is our "main" function.
 +
int main(int argc, char *argv[])  //argc and argv stand for "Argument Count" and "Argument Vector"
 +
{
 +
 
 +
    std::cout << "Hello World!" << std::endl; //use cout to print the text "Hello World!" to the console.
 +
  return 0; //return 0 and exit.
 +
}
 +
</source>
 +
}}

Revision as of 19:56, 22 November 2011

C++ is a compiled low-level programming language. It is an enhancement of the language C. The name 'C++' comes from the increment operator in C, which is "++" therefore C++

Because C++ is a compiled language, you will need a compiler to compile your code. Most Linux distributions come with the proper tools such as gcc, and gdb installed. If you do not have these installed, you can install through your respective package manager.

 Debian/Ubuntu:   apt get build-essential
 Arch Linux:      pacman -S base-devel

Hello World

Here is a quick example of a "Hello World" application in C++, and how to compile it.

The code

 
 #include <iostream> //preprocessor directive, tells the compiler to 'include' the file "iostream"
//This is a comment by the way.
/*
so is this.
except
it's
a multi-line
comment.
*/
//The compiler ignores comments.
 
//here is our "main" function.
int main(int argc, char *argv[])  //argc and argv stand for "Argument Count" and "Argument Vector"
{
 
    std::cout << "Hello World!" << std::endl; //use cout to print the text "Hello World!" to the console.
   return 0; //return 0 and exit.
}