×
Create a new article
Write your page title here:
We currently have 190 articles on Open Eggbert. Type your article name above or click on one of the titles below and start writing!



Open Eggbert
190Articles

C++: Difference between revisions

No edit summary
m (Robertvokac moved page Speedy Blupi/Used technologies/C++ to C++ without leaving a redirect)
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Author:''' Bjarne Stroustrup '''Supported programming paradigms:''' procedural, object-oriented, generic. Based on on the C programming language. OOP in C++ was inspired by the Simula64 programming language. All C programs are valid C++ programs. The name of the C++ programming language is related to the incremental operator "++". How to create a C++ program: compiling to object files, linking object files to an executable version of the program.
'''Author:''' Bjarne Stroustrup '''Supported programming paradigms:''' procedural, object-oriented, generic. Based on on the C programming language. OOP in C++ was inspired by the Simula64 programming language. All C programs are valid C++ programs. The name of the C++ programming language is related to the incremental operator "++". How to create a C++ program: compiling to object files, linking object files to an executable version of the program.


= Function main() =
= Introduction =
 
== Functions ==
C++ program consists of functions. Function consists of statements. Each statement must end with the semicolon character.
 
Prototype vs implementation.
 
== Function main() ==
Function main() is the entrypoint of an C++ application.
Function main() is the entrypoint of an C++ application.


= Console =
'''Variants:'''
 
* int main() {return 0;}
* void main() {return 0;}
* void main(void) {return 0;}
* int main(void) {return 0;}
 
== Console ==
How to delay program and wait for the press of the key Enter: cin.get();
How to delay program and wait for the press of the key Enter: cin.get();


= Comments =
Printing text to console: cout << "some text"; //operator overloading: <<
One line: //comment
 
Reading text from console: cin >> carrots;
 
How to print end line: "\n" or std::endl
 
== Comments ==
One line: // comment


Multi line: /* comment */
Multi line: /* comment */
== Preprocessor directives ==
=== #include <iostream> ===
Includes file iostream
=== #define INT_MAX 32767 ===
Replaces all INT_MAX occurences by 32767
== Importing namespaces ==
using namespace std;
using std::count;
== C++ statement ==
Each C++ statement must be ended with the semicolon character ;
=== Declaration (statement type) ===
This allocates memory.
Example: int carrots;
=== Assignment (statement type) ===
Example: carrots = 15;
=== Initialization (statement type) ===
int carrots = 15;
//or
int carrots (15);
== Key words ==
return, void, int, const
And others
== Variable ==
Variable is named location in the memory with its type definition.
You can get the location in the memory with the & operator.
= Data types =
== Void ==
Empty set of values, cannot be used as the type of variable.
== Integral ==
short: at least 16 bits
int: at least the same size as short (since -32768 until 32 767)
long: at least 32 bits, at least the same size as int
long long (since C++ 99): at least 64 bits, at least the same size as long
unsigned: unsigned short, unsigned int, unsigned long, unsigned long long
Octal: starts with 0
Hexadecimal: starts with 0x or 0X
char
wchar_t
bool
== Floating-point ==
= Combined data types =
= Operators =
== sizeof ==
= Class =
Class is user defined type
[[Category:Technologies used by Speedy Blupi]]

Latest revision as of 19:23, 8 November 2024

Author: Bjarne Stroustrup Supported programming paradigms: procedural, object-oriented, generic. Based on on the C programming language. OOP in C++ was inspired by the Simula64 programming language. All C programs are valid C++ programs. The name of the C++ programming language is related to the incremental operator "++". How to create a C++ program: compiling to object files, linking object files to an executable version of the program.

Introduction

Functions

C++ program consists of functions. Function consists of statements. Each statement must end with the semicolon character.

Prototype vs implementation.

Function main()

Function main() is the entrypoint of an C++ application.

Variants:

  • int main() {return 0;}
  • void main() {return 0;}
  • void main(void) {return 0;}
  • int main(void) {return 0;}

Console

How to delay program and wait for the press of the key Enter: cin.get();

Printing text to console: cout << "some text"; //operator overloading: <<

Reading text from console: cin >> carrots;

How to print end line: "\n" or std::endl

Comments

One line: // comment

Multi line: /* comment */

Preprocessor directives

#include <iostream>

Includes file iostream

#define INT_MAX 32767

Replaces all INT_MAX occurences by 32767

Importing namespaces

using namespace std;

using std::count;

C++ statement

Each C++ statement must be ended with the semicolon character ;

Declaration (statement type)

This allocates memory.

Example: int carrots;

Assignment (statement type)

Example: carrots = 15;

Initialization (statement type)

int carrots = 15;

//or

int carrots (15);

Key words

return, void, int, const

And others

Variable

Variable is named location in the memory with its type definition.

You can get the location in the memory with the & operator.

Data types

Void

Empty set of values, cannot be used as the type of variable.

Integral

short: at least 16 bits

int: at least the same size as short (since -32768 until 32 767)

long: at least 32 bits, at least the same size as int

long long (since C++ 99): at least 64 bits, at least the same size as long

unsigned: unsigned short, unsigned int, unsigned long, unsigned long long

Octal: starts with 0

Hexadecimal: starts with 0x or 0X


char

wchar_t

bool

Floating-point

Combined data types

Operators

sizeof

Class

Class is user defined type