C++ - Cheat Sheet
Jump to navigation
Jump to search
|
What can we help you find? |
Random | ||||||||||||||||
| Home | Testing | Automation | AI | IoT | OS | RF | Data | Development | References | Tools | Wisdom | Inspiration | Investing | History | Fun | POC | Help |
This C++ cheat sheet captures concepts and ideas discovered when developing and using C++
Terminology
Research
- Learn C++ Programming
- C++ Introduction
- C++ and CLion Introduction
- C++ Examples
- C++ All About Strings
- C++ Structures (struct)
- C++ Pointers
- Convert char* to string in C++
Projects
Language Syntax
|
What can we help you find? |
Random | ||||||||||||||||
| Home | Testing | Automation | AI | IoT | OS | RF | Data | Development | References | Tools | Wisdom | Inspiration | Investing | History | Fun | POC | Help |
| Functionality
(edit) |
Language | |||||||
|---|---|---|---|---|---|---|---|---|
| Family | Specific | Details | AppleScript | C++ | JavaScript | Ruby | Shell | Visual Basic |
Documentation
|
Comment
|
-- This is a comment
|
// This is a comment
|
// This is a comment
|
# This is a comment
|
# This is a comment
|
' This is a comment
| |
Collection
|
Array
|
struct myInfo { int myNum; string myName;};
|
||||||
Collection
|
Structure (aka struct)
|
A way to group several related variables into one place. | if a > b
|
|||||
Comparison
|
Greater Than
|
if a > b
|
if a > b
|
If a > b Then
| ||||
Comparison
|
Less Than
|
if a < b
|
if a < b
|
If a < b Then
| ||||
Comparison
|
Equal To
|
if a == b
|
||||||
Comparison
|
Not Equal To
|
if a != b
|
if a != b
|
If a <> b Then
| ||||
Computation
|
Addition
|
a = b + c
|
a = b + c
| |||||
Computation
|
Division
|
a = b / c
|
a = b / c
| |||||
Computation
|
Multiplication
|
a = b * c
|
a = b * c
| |||||
Computation
|
Subtraction
|
a = b - c
|
a = b - c
| |||||
Conditional
|
Case
|
break; case y: // code break; default:// code } |
case fruit when 'Apple' result = '1 a day' when 'Pear' result = '1 a week' else result = 'unknown' end
|
Select Case(Fruit) Case "Apple" Result = "1 a day" Case "Pear" Result = "1 a week" Case Else Result = "Unknown" End Select
| ||||
Conditional
|
If - And - Then
|
If a = 1 and b = 2 Then
| ||||||
Conditional
|
If - Or - Then
|
If a = 1 of b = 1 Then
| ||||||
Conditional
|
If - Then - Else
|
if (time < 18) { cout << "Good day.";} else { cout << "Good evening.";}
|
if result == 'pass' puts 'Pass' elsif result == 'fail' #Note how elsif is spelled puts 'Fail' else puts 'Other' end
|
If a = b Then print "a equals b" ElseIf a = c Then print "a equals c" Else print "a does not equal b" End If
| ||||
| Conditional | Ternary | Short-hand if else statement. | result = (time < 18) ? "Good day." : "Good evening.";
|
var_is_greater_than_three = (var > 3 ? true : false) | ||||
Date
|
Addition
|
EstHours = DateAdd("d",Days,Today)
| ||||||
Date
|
Difference
|
EstHours = DateDiff("h",FirstDate, SecondDate)
| ||||||
Dialog
|
display dialog "Hello World"
|
|
||||||
IO
|
Input
|
cin >> x; // Get user input
|
||||||
IO
|
Output
|
cout << "Hello World!";
|
puts "Hello World"
|
echo "Hello World"
|
||||
IO
|
Serial Monitor or Terminal
|
Serial.begin(115200);Serial.println("Hello\nWorld");"
|
puts "Hello World"
|
|||||
Load URL
|
open location "https://gregpaskal.com/"
|
|||||||
Logical
|
And
|
Returns true if both are true | if a = 1 && b = 2
|
|||||
Logical
|
Or
|
Returns true if one or the other are true | if a = 1 || b = 2
|
|||||
Logical
|
Not
|
Returns true if results are false | if a != 1
|
|||||
Loop
|
Do
|
do { cout << i; i++;}while (i < 5);
|
i = 0 Do Print "Hello" i = i + 1 If i = "" Then Exit Do End If Loop until i > 5
| |||||
Loop
|
For
|
for (int i = 0; i < 5; i++) { cout << i;}
|
for i in 1..10 puts i end
|
For i = 1 to 10 print i Next
| ||||
Loop
|
While
|
while (i < 5) { cout << i; i++;}
|
||||||
Speak
|
||||||||
String
|
Concatanation
|
Joining multiple strings together
|
set theDialogText to "The current date and time is " & (current date) & "."
|
fullName = firstName + lastName;
|
filespec = filepath + filename
|
Result = "Age = " & MyAge
| ||
String
|
Interpolation
|
(Not possible in AppleScript)
|
Result = "Hello #{first_name}"
|
|||||
String
|
Length
|
Get the length of a string
|
theLen = txt.length();
|
|||||
String
|
New line
|
Start a new line
|
\n
|
|||||
Type
|
Bool
|
bool myBoolean = true;
|
||||||
Type
|
Double
|
double myLargeNum = 556.9923234;
|
||||||
Type
|
Character
|
Store a single character
|
char myLetter = 'D';
|
|||||
Type
|
Float
|
float myFloatNum = 5.99;
|
||||||
Type
|
Integer
|
int myNum = 15;
|
a = Int(12.34)
| |||||
Type
|
String
|
string myText = "Hello";
|
||||||
| Time | Delay | Waiting for a designated delay | delay(250); | sleep(1) | ||||
Variable
|
Class
|
Shared by all instances of a class
|
@@URL = 'www.mysite.com'
|
|||||
Variable
|
Constant
|
Value to stay the same for the duration of the code execution. Changing value will generate warning.
|
const float PI = 3.14;
|
URL = 'www.mysite.com'
|
||||
Variable
|
Global
|
Shared across the entire program
|
$URL = 'www.mysite.com'
|
|||||
Variable
|
Instance
|
Belongs to the object itself
|
@URL = 'www.mysite.com'
|
|||||
Variable
|
Local
|
Only accessible from the block it's initialize from
|
set myName to "Bob Smith"
|
a = 1
|
ma_name="Bob Smith"
|
a = 1
| ||
Variable
|
Pre-defined
|
__FILE__ (Current File) __dir__ (Current Directory) __LINE__ (Current Line)
|
MyFile = __FILE__
|
|||||