100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
notes for all the topics and skills of computer science $7.49   Add to cart

Other

notes for all the topics and skills of computer science

 1 view  0 purchase
  • Course
  • Institution

notes for all the topics and skills of computer science

Preview 4 out of 708  pages

  • November 17, 2021
  • 708
  • 2021/2022
  • Other
  • Unknown
avatar-seller
C++
C++
Notes for Professionals




Notes for Professionals




600+ pages
of professional hints and tricks


Disclaimer
GoalKicker.com This is an unocial free book created for educational purposes and is
not aliated with ocial C++ group(s) or company(s).
Free Programming Books All trademarks and registered trademarks are
the property of their respective owners

,Contents
About ................................................................................................................................................................................... 1
Chapter 1: Getting started with C++ .................................................................................................................... 2
Section 1.1: Hello World ................................................................................................................................................. 2
Section 1.2: Comments .................................................................................................................................................. 3
Section 1.3: The standard C++ compilation process .................................................................................................. 5
Section 1.4: Function ...................................................................................................................................................... 5
Section 1.5: Visibility of function prototypes and declarations ................................................................................. 8
Section 1.6: Preprocessor .............................................................................................................................................. 9
Chapter 2: Literals ...................................................................................................................................................... 11
Section 2.1: this ............................................................................................................................................................. 11
Section 2.2: Integer literal ........................................................................................................................................... 11
Section 2.3: true ........................................................................................................................................................... 12
Section 2.4: false .......................................................................................................................................................... 13
Section 2.5: nullptr ....................................................................................................................................................... 13
Chapter 3: operator precedence ........................................................................................................................ 14
Section 3.1: Logical && and || operators: short-circuit .............................................................................................. 14
Section 3.2: Unary Operators ..................................................................................................................................... 15
Section 3.3: Arithmetic operators .............................................................................................................................. 15
Section 3.4: Logical AND and OR operators ............................................................................................................ 16
Chapter 4: Floating Point Arithmetic ............................................................................................................... 17
Section 4.1: Floating Point Numbers are Weird ........................................................................................................ 17
Chapter 5: Bit Operators ........................................................................................................................................ 18
Section 5.1: | - bitwise OR ............................................................................................................................................ 18
Section 5.2: ^ - bitwise XOR (exclusive OR) .............................................................................................................. 18
Section 5.3: & - bitwise AND ....................................................................................................................................... 20
Section 5.4: << - left shift ............................................................................................................................................. 20
Section 5.5: >> - right shift .......................................................................................................................................... 21
Chapter 6: Bit Manipulation ................................................................................................................................... 23
Section 6.1: Remove rightmost set bit ....................................................................................................................... 23
Section 6.2: Set all bits ................................................................................................................................................ 23
Section 6.3: Toggling a bit .......................................................................................................................................... 23
Section 6.4: Checking a bit ......................................................................................................................................... 23
Section 6.5: Counting bits set ..................................................................................................................................... 24
Section 6.6: Check if an integer is a power of 2 ....................................................................................................... 25
Section 6.7: Setting a bit ............................................................................................................................................. 25
Section 6.8: Clearing a bit ........................................................................................................................................... 25
Section 6.9: Changing the nth bit to x ....................................................................................................................... 25
Section 6.10: Bit Manipulation Application: Small to Capital Letter ........................................................................ 26
Chapter 7: Bit fields ................................................................................................................................................... 27
Section 7.1: Declaration and Usage ........................................................................................................................... 27
Chapter 8: Arrays ....................................................................................................................................................... 28
Section 8.1: Array initialization .................................................................................................................................... 28
Section 8.2: A fixed size raw array matrix (that is, a 2D raw array) ...................................................................... 29
Section 8.3: Dynamically sized raw array ................................................................................................................. 29
Section 8.4: Array size: type safe at compile time ................................................................................................... 30
Section 8.5: Expanding dynamic size array by using std::vector ........................................................................... 31

, Section 8.6: A dynamic size matrix using std::vector for storage .......................................................................... 32
Chapter 9: Iterators ................................................................................................................................................... 35
Section 9.1: Overview ................................................................................................................................................... 35
Section 9.2: Vector Iterator ........................................................................................................................................ 38
Section 9.3: Map Iterator ............................................................................................................................................ 38
Section 9.4: Reverse Iterators .................................................................................................................................... 39
Section 9.5: Stream Iterators ...................................................................................................................................... 40
Section 9.6: C Iterators (Pointers) .............................................................................................................................. 40
Section 9.7: Write your own generator-backed iterator ......................................................................................... 41
Chapter 10: Basic input/output in c++ ............................................................................................................. 43
Section 10.1: user input and standard output ........................................................................................................... 43
Chapter 11: Loops ........................................................................................................................................................ 44
Section 11.1: Range-Based For .................................................................................................................................... 44
Section 11.2: For loop ................................................................................................................................................... 46
Section 11.3: While loop ............................................................................................................................................... 48
Section 11.4: Do-while loop .......................................................................................................................................... 49
Section 11.5: Loop Control statements : Break and Continue .................................................................................. 50
Section 11.6: Declaration of variables in conditions ................................................................................................. 51
Section 11.7: Range-for over a sub-range ................................................................................................................. 52
Chapter 12: File I/O .................................................................................................................................................... 54
Section 12.1: Writing to a file ....................................................................................................................................... 54
Section 12.2: Opening a file ........................................................................................................................................ 54
Section 12.3: Reading from a file ............................................................................................................................... 55
Section 12.4: Opening modes ..................................................................................................................................... 57
Section 12.5: Reading an ASCII file into a std::string ................................................................................................ 58
Section 12.6: Writing files with non-standard locale settings .................................................................................. 59
Section 12.7: Checking end of file inside a loop condition, bad practice? ............................................................. 60
Section 12.8: Flushing a stream .................................................................................................................................. 61
Section 12.9: Reading a file into a container ............................................................................................................. 61
Section 12.10: Copying a file ....................................................................................................................................... 62
Section 12.11: Closing a file .......................................................................................................................................... 62
Section 12.12: Reading a `struct` from a formatted text file .................................................................................... 63
Chapter 13: C++ Streams ......................................................................................................................................... 65
Section 13.1: String streams ........................................................................................................................................ 65
Section 13.2: Printing collections with iostream ........................................................................................................ 66
Chapter 14: Stream manipulators ..................................................................................................................... 68
Section 14.1: Stream manipulators ............................................................................................................................. 68
Section 14.2: Output stream manipulators ............................................................................................................... 73
Section 14.3: Input stream manipulators ................................................................................................................... 75
Chapter 15: Flow Control ......................................................................................................................................... 77
Section 15.1: case ......................................................................................................................................................... 77
Section 15.2: switch ...................................................................................................................................................... 77
Section 15.3: catch ....................................................................................................................................................... 77
Section 15.4: throw ....................................................................................................................................................... 78
Section 15.5: default .................................................................................................................................................... 79
Section 15.6: try ............................................................................................................................................................ 79
Section 15.7: if ............................................................................................................................................................... 79
Section 15.8: else .......................................................................................................................................................... 80
Section 15.9: Conditional Structures: if, if..else ........................................................................................................... 80

, Section 15.10: goto ....................................................................................................................................................... 81
Section 15.11: Jump statements : break, continue, goto, exit ................................................................................... 81
Section 15.12: return ..................................................................................................................................................... 84
Chapter 16: Metaprogramming ........................................................................................................................... 86
Section 16.1: Calculating Factorials ............................................................................................................................ 86
Section 16.2: Iterating over a parameter pack ......................................................................................................... 88
Section 16.3: Iterating with std::integer_sequence ................................................................................................... 89
Section 16.4: Tag Dispatching .................................................................................................................................... 90
Section 16.5: Detect Whether Expression is Valid ..................................................................................................... 90
Section 16.6: If-then-else ............................................................................................................................................. 92
Section 16.7: Manual distinction of types when given any type T .......................................................................... 92
Section 16.8: Calculating power with C++11 (and higher) ......................................................................................... 93
Section 16.9: Generic Min/Max with variable argument count ............................................................................... 94
Chapter 17: const keyword .................................................................................................................................... 95
Section 17.1: Avoiding duplication of code in const and non-const getter methods ............................................ 95
Section 17.2: Const member functions ...................................................................................................................... 96
Section 17.3: Const local variables ............................................................................................................................. 97
Section 17.4: Const pointers ........................................................................................................................................ 97
Chapter 18: mutable keyword .............................................................................................................................. 99
Section 18.1: mutable lambdas ................................................................................................................................... 99
Section 18.2: non-static class member modifier ...................................................................................................... 99
Chapter 19: Friend keyword ................................................................................................................................ 101
Section 19.1: Friend function ..................................................................................................................................... 101
Section 19.2: Friend method ..................................................................................................................................... 102
Section 19.3: Friend class .......................................................................................................................................... 102
Chapter 20: Type Keywords ............................................................................................................................... 104
Section 20.1: class ...................................................................................................................................................... 104
Section 20.2: enum .................................................................................................................................................... 105
Section 20.3: struct .................................................................................................................................................... 106
Section 20.4: union .................................................................................................................................................... 106
Chapter 21: Basic Type Keywords .................................................................................................................... 108
Section 21.1: char ....................................................................................................................................................... 108
Section 21.2: char16_t ................................................................................................................................................ 108
Section 21.3: char32_t ............................................................................................................................................... 108
Section 21.4: int .......................................................................................................................................................... 108
Section 21.5: void ....................................................................................................................................................... 108
Section 21.6: wchar_t ................................................................................................................................................ 109
Section 21.7: float ....................................................................................................................................................... 109
Section 21.8: double ................................................................................................................................................... 109
Section 21.9: long ....................................................................................................................................................... 109
Section 21.10: short .................................................................................................................................................... 110
Section 21.11: bool ...................................................................................................................................................... 110
Chapter 22: Variable Declaration Keywords .............................................................................................. 111
Section 22.1: decltype ............................................................................................................................................... 111
Section 22.2: const .................................................................................................................................................... 111
Section 22.3: volatile ................................................................................................................................................. 112
Section 22.4: signed .................................................................................................................................................. 112
Section 22.5: unsigned .............................................................................................................................................. 112
Chapter 23: Keywords ............................................................................................................................................ 114

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller therakshit28. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76800 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.49
  • (0)
  Add to cart