Chapter 3 Strings, Vectors and Arrays

Ways to Initialize a string

String Operations


  1. cin discards any leading whitespace, but getline() doesn’t.
  2. size() returns a string::size_type. It is a unsigned type.
  3. Never ever compare size_type with a negative number!

  4. When using “+” operator, avoid following errors

  5. String literals, such as “abc”, are not strings.

Function: decltype()

Returns the type of its operand.

Ways to Initialize a vector

Function: push_back()

Takes a value and “pushes” that value as a new last element onto the “back” of the vector.

vector Operations

Standard Container Iterator Operations

Note: 1. In for loops’ condition part, use != instead of < or >, because all the library containers have iterators that define the == and != operators and most of those iterators do not have the < operator.

Object-Oriented Python

Use keyword class to start a class. Class names are capitalized.

Class can have some properties.

Continue Reading…

Python Collections

list1 + list2

Note: l1 + l2 won’t change the value of l1


Append a new item with value x to the end of the array

Continue Reading…

Python Basics

Python Basics

Get Help

  1. Enter the python3 command-line interpretor

  2. Get help for a function, e.g. print(...)

  3. Get help for a class, e.g. class str

  4. Find what variables and methods are available on a class, e.g. class str

  5. Get help for a class method such as rjust(), rjust() is belong to class str

Continue Reading…

Lecture 9 Scroll View, Multithreading

Scroll View


The main queue

Continue Reading…