C++ - Cheat Sheet

From Craft of Testing - Wiki
Revision as of 21:20, 4 April 2025 by Gregpaskal (talk | contribs) (Created page with "{{: Header_Nav}} This C++ cheat sheet captures concepts and ideas discovered when developing and using C++ == Terminology == * == Research == * [https://www.programiz.com/cpp-programming Learn C++ Programming] * [https://www.w3schools.com/cpp/cpp_intro.asp C++ Introduction] * [https://www.youtube.com/watch?v=aOTB-OExtdM C++ and CLion Introduction] * [https://www.w3schools.com/cpp/cpp_examples.asp C++ Examples] * [https://www.fluentcpp.com/2017/12/19/build-strings-from...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

What can we help you find?

Language Syntax
XPath Examples

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

Projects

Language Syntax

What can we help you find?

Language Syntax
XPath Examples

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

switch(expression {case x: // code

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"

var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.displayAlert("This is a message");

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__