Skip to content

List of C++ topics and their code snippets!

Notifications You must be signed in to change notification settings

Singularity-Coder/Instant-Cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

alt text

Instant-Cpp

List of C++ topics and their code snippets!

Theory

  • C++ supports classes and objects, while C does not.
  • Escape Sequences: It forces the cursor to change its position.
    • \n Creates a new line.
    • \t Creates a horizontal tab.
    • \ Inserts a backslash character ()
    • " Inserts a double quote character
  • << insertion operator
  • extraction operator

Package definition and imports

#include <iostream>
using namespace std;

Comments

// This is a comment

/* This is a multi-line comment.
   You can add some helpful text here. */

Printing to Console

printf("Hello World \n");
std::cout << "Hello World!";

Data Types

int number; // 2 or 4 bytes. ex: -n, 0, n
float storeCount; // 4 bytes. ex: -0.3, 0, 0.0193
double pi; // 8 bytes. ex: -0.01242324, 0, 0.01234232 
char letter; // 1 byte. ex: 'a', 'z'
string text; // ex: "Hello"
bool isValid; // 1 byte. ex: true or false

Constants

const int pi = 3.14;

Variables

int myNum = 15;

int myNum2;
myNum2 = 15;

Booleans

cout << true; // 1
cout << false; // 0

Scientific Notation

float num1 = 35e5; // This means 3500000 or 35 * 10^5
double num2 = 35E5;

Operators

Arithmetic Operators

j + k
j - k
j * k
j / k
j % k
++j
--k

Assignment Operators

j += 5;
j -= 2;
j *= 4;
j /= 9;

Conditionals

Loops

Collections

Classes

Functions

int main() {
    std::cout << "Hello World!";
    return 0; // Ends the main function
}

Instantiation and Intitialization

Inheritance

Composition


References


How to edit?

About

List of C++ topics and their code snippets!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published