搜尋此網誌

2025年12月16日星期二

Queues and Stacks

Queue (FIFO)

  • Definition: A queue is a linear data structure that follows the First In, First Out (FIFO) principle.
  • Analogy: Think of people lining up at a ticket counter. The first person to join the line is the first to be served.
#include <iostream>
#include <queue>
using namespace std;

int main() {
    queue<int> q;

    // Enqueue elements into the queue
    q.push(10);
    q.push(20);
    q.push(30);

    cout << "Queue (FIFO):" << endl;
    while (!q.empty()) {
        cout << q.front() << " ";  // Access the front element
        q.pop();                   // Remove the front element
    }
    return 0;
}

while (!q.empty())
q → This is your queue object (e.g., queue q;).
q.empty() → This function returns true if the queue has no elements, otherwise false.
!q.empty() → The ! (logical NOT) operator flips the result:
If the queue is not empty, !q.empty() is true.
If the queue is empty, !q.empty() is false.
while (!q.empty()) → This loop continues to run as long as the queue has elements inside.

Stack (LIFO)

  • Definition: A stack is a linear data structure that follows the Last In, First Out (LIFO) principle.
  • Analogy: Imagine a stack of plates. The last plate placed on top is the first one you take off.
#include <iostream>
#include <stack>
using namespace std;

int main() {
    stack<int> s;

    // Push elements onto the stack
    s.push(10);
    s.push(20);
    s.push(30);

    cout << "Stack (LIFO):" << endl;
    while (!s.empty()) {
        cout << s.top() << " ";  // Access the top element
        s.pop();                 // Remove the top element
    }
    return 0;
}

Microsoft Copilot

Offer given

hereby: (in legal documents, etc.) as a result of this statement, and in a way that makes something legal

"Coursing through" means to flow, run, or move rapidly and powerfully, often used for liquids like blood or emotions (joy, fear, adrenaline) moving through the body, or for ideas/energy moving through a system, like news or excitement through people. It implies a strong, energetic, and often unstoppable flow, like water in a stream or a wave of feeling.

skit: a short piece of humorous writing or a performance that makes fun of somebody/something by copying them

deadpan: without any expression or emotion; often pretending to be serious when you are joking

absurd: ridiculously unreasonable, unsound, or incongruous

monologue: a long speech in a play, film, etc. spoken by one actor, especially when alone

wacky: funny in a slightly crazy way

prom: (especially in the US) a formal dance, especially one that is held at a high school

low-key: quiet and not attracting a lot of attention or excitement

pomp: the impressive clothes, decorations, music, etc. and traditional customs that are part of an official occasion or ceremony

dashing: (usually of a man) attractive and full of confidence

quad: an open square area that has buildings all around it, especially in a school or college

straggler: a person or an animal that is among the last or the slowest in a group to do something, for example, to finish a race or leave a place

assertion: a statement saying that you strongly believe something to be true

exhilarating: very exciting and great fun

orthodontist: a dentist who treats problems relating to the position of the teeth and jaws

grinding: (of a sound) rough and unpleasant to listen to

vow: to make a formal and serious promise to do something or a formal statement that is true

toggle: to press a key or set of keys on a computer keyboard in order to turn a feature on or off, or to move from one program, etc. to another

subsist: to manage to stay alive, especially with limited food or money

tease: to laugh at somebody and make jokes about them, either in a friendly way or in order to annoy them or make them embarrassed

oddball: behaving in a strange or unusual way

overlook: to fail to see or notice something

bunch: (informal, especially North American English) a large amount of something; a large number of things or people

subroutine: a set of instructions which perform a task within a program

peerless: better than all others of its kind

relentlessly: in a way that continues strongly, without stopping, giving up or getting less strong

prod: to try to make somebody do something, especially when they are unwilling

leapfrog: to get to a higher position or rank by going past somebody else or by missing out some stages

hotshot: a person who is extremely successful in their career or at a particular sport

notion: an idea, a belief or an understanding of something

stature: the importance and respect that a person has because of their ability and achievements

upstart: a person who has just started in a new position or job but who behaves as if they are more important than other people, in a way that is annoying

laud: to praise somebody/something

visionary: original and showing the ability to think about or plan the future with great imagination and intelligence

"Bonneville" refers to the Bonneville Power Administration (BPA), where a teenage Bill Gates and Paul Allen did one of their first major software jobs in 1973, writing code for the power grid's control system for defense contractor TRW.

forgo: to decide not to have or do something that you would like to have or do

nascent: beginning to exist; not yet fully developed


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com/dictionary

Google AI overview

2025年12月9日星期二

English with Maggie

Would you do it for me?

比較像在問意願。

Could you do it for me?

比較像在問能力。


Regular verbs +ed 變過去式

used /use-d/ but not /use-凸/

"ed"的三個發音: /id/ /t/ /d/

/t/ /d/ consonants 收尾用 /id/ 相對大聲

wanted: /wan-tid/

needed: /nee-did/

decided: /de-cai-did/


voiced sound:

l, n, r, b, g, m, z

令 vocal cords 震動

called: /call-d/ but not /call-凸/

cleaned: /clean-d/ but not /clean-凸/

offered: /offer-d/ but not /offer-凸/

loved: /love-d/


voiceless sound:

f, s, th, ch, sh, p, k

不令 vocal cords 震動

stopped: /stop-t/ 而不是 /stop-凸/

looked: /look-t/

helped: /help-t/

喀布爾

2025年12月8日星期一

Containers and Adapters

In C++ STL, sequence containers are data structures that store elements in a linear order, allowing sequential access. The main sequence containers are: array, vector, deque, list, and forward_list.

iteration: the process of repeating a mathematical or computing process or set of instructions again and again, each time applying it to the result of the previous stage

dribble (something) (+ adv./prep.) (in football (soccer) and some other sports) to move the ball along with several short kicks, hits or bounces


for (const auto& action : recentActions)

The above line is a range-based for loop in C++.

for → Starts the loop.

const auto& action

    auto deduces the type of each element in recentActions.

    & means we’re iterating by reference (no copy is made).

    const ensures the element cannot be modified inside the loop.

: recentActions → The container we’re iterating over (e.g., std::vector, std::list, etc.).

deduce: to form an opinion about something based on the information or evidence that is available

recentActions is the container (e.g., std::vector, std::list, etc.) that holds multiple elements.

action is a reference to each individual element inside recentActions as the loop iterates.


In C++, std::list is a sequence container implemented as a doubly linked list. It allows fast insertions and deletions anywhere in the sequence but does not support random access like arrays or vectors.


In C++, associative containers are part of the Standard Template Library (STL) that store elements in a way that allows fast retrieval based on keys rather than positions. The main ordered associative containers are: set, multiset, map, and multimap.


Defined in the <set> header as std::set<T>.

Stores unique elements in a sorted order.

Internally implemented as a balanced binary search tree (usually a Red-Black Tree).

Provides logarithmic time complexity (O(log n)) for insertion, deletion, and search.


A side-scrolling video game (alternatively side-scroller) is a video game viewed from a side-view camera angle where the screen follows the player as they move left or right.


The dot (.) operator in C++ is one of the fundamental operators used for member access.

The dot operator (.) is used to access members (variables, functions, or nested types) of an object, struct, or class directly.

It works when you have an object (not a pointer).


The std::pair class in C++ is a simple but powerful utility that lets you store two values together as a single unit. It’s defined in the <utility>  header.

std::pair<std::string, int> playerStats("Alice", 75);

The above line of code is creating a std::pair object named playerStats with two values:

first"Alice" (a std::string)

second75 (an int)


Defined in the <map> header as std::map<Key,T>.

Stores key–value pairs where:

    Key → unique identifier.

    Value (T) → data associated with the key.

Internally implemented as a balanced binary search tree (usually a Red-Black Tree).

Keys are always kept in sorted order (by default using std::less<Key>).


In C++, unordered containers are part of the STL that store elements in hash tables rather than sorted trees. They provide average constant-time (O(1)) performance for insertion, deletion, and lookup, but do not maintain any order of elements.


Container adapters are special containers that provide a restricted interface built on top of other sequence containers (like deque, list, or vector).

They don’t store elements in a unique way themselves; instead, they adapt existing containers to provide specific behaviors.

Defined in the <queue> and <stack> headers.


Last in First out

It’s a data access principle used in computer science and programming.

Think of it like a stack of plates: the last plate you put on top is the first one you take off.

In C++, this principle is implemented using the std::stack container adapter.

empty()

Checks whether the stack has any elements.

top()

Returns a reference to the top element of the stack (the last pushed element).

Does not remove the element.

pop()

Removes the top element from the stack. 


FIFO is the opposite of LIFO (Last In, First Out).

Think of it like a line at a store: the first person to enter the line is the first person served.

In C++, FIFO is implemented using the std::queue container adapter.

front() gives you a reference to the first element in the container.

Does not remove the element (unlike pop() in a queue).

Undefined behavior if called on an empty container (so always check with empty() first).


Defined in the <queue> header as std::priority_queue.

Stores elements in a way that the highest priority element is always accessible at the top.

Internally implemented using a heap structure (by default, a max-heap built on top of a std::vector).

std::priority_queue<int> aiTasks;

std::priority_queue → A priority queue of integers.

aiTasks → The variable name.

By default, std::priority_queue is a max-heap, meaning the largest integer will always be at the top.


In C++ STL, container adapters are special wrappers that provide a specialized interface on top of existing sequence containers (like deque, list, or vector). Instead of exposing all the operations of the underlying container, they restrict and tailor the interface to enforce a particular usage pattern.


Microsoft Copilot

Overview of STL

In C++’s Standard Template Library (STL), containers store data, iterators traverse it, algorithms process it, and functors customize operations.

In computer science, traversing means systematically visiting every element in a data structure (like an array, list, tree, or graph) to access, process, or use the data, often using loops or specific algorithms (Depth-First Search, Breadth-First Search) to move from one element to the next, ensuring each item is handled.

Overloading the parenthesis operator () in computer science, particularly in C++, allows an object of a class to be called or used as if it were a function. This is also referred to as creating a "functor" or "function object."

Microsoft Copilot
Google AI overview

錯則勿憚改

The axiom that you learn more from your failures than your successes is trite but absolutely true.


oversee: to watch somebody/something and make sure that a job or an activity is done correctly

TRW: Transformer Repairing Works

venture: a business project or activity, especially one that involves taking risks

tangle: a twisted mass of threads, hair, etc. that cannot be easily separated

omnivorous: having wide interests in a particular area or activity

prospect: the chances of being successful

desperate: feeling or showing that you have little hope and are ready to do anything without worrying about danger to yourself or others

gig: (especially North American English, informal) a job, especially a temporary one

Sherwood Forest, in Nottinghamshire, England, is a legendary ancient woodland famous as the legendary hideout of the outlaw hero Robin Hood and home to Europe's largest collection of ancient oaks, like the iconic Major Oak.

outrun: to run faster or further than somebody/something

lava: hot liquid rock that comes out of a volcano

Krakatoa, volcano on Rakata Island in the Sunda Strait between Java and Sumatra, Indonesia. Its explosive eruption in 1883 was one of the most catastrophic in history.

A power grid is the interconnected network that generates, transmits, and distributes electricity from power plants to consumers, featuring generation, high-voltage transmission lines, substations (to adjust voltage), and local distribution networks.

scramble: to move quickly, especially with difficulty, using your hands to help you

Grand Coulee is an ancient river bed in the US state of Washington.

literally: exactly

DEC: Digital Equipment Corporation

sift: to examine something very carefully in order to decide what is important or useful or to find something important

deluge: a large number of things that happen or arrive at the same time

downtime: the time during which a machine, especially a computer, is not working

crank up: to make a machine, etc. work or work at a higher level

diner: (in the US) a small, usually cheap, restaurant

baseload: the permanent minimum load that a power supply system is required to deliver

churn out: to produce something quickly and in large amounts

testament: a thing that shows that something else exists or is true

seasoned: (of a person) having a lot of experience of a particular activity

maniac: behaving in an extremely dangerous, violent, wild or crazy way

close-cropped: (of hair, grass, etc.) cut very short

glitch: a small problem or fault that stops something working successfully

haunted: (of an expression on somebody’s face) showing that somebody is very worried

fiasco: something that does not succeed, often in a way that makes people feel embarrassed

origami: the Japanese art of folding paper into attractive shapes

vigilant: alert, watchful

axiom: a rule or principle that most people believe to be true

trite: (of a remark, an opinion, etc.) boring because it has been expressed so many times before; not original


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Google AI overview

www.britannica.com

2025年12月2日星期二

Template class

GameEntity(T xPos, T yPos) : x(xPos), y(yPos) {}

That’s a constructor definition in C++ using an initializer list.

GameEntity(T xPos, T yPos)

This is the constructor for the class GameEntity. It takes two parameters of type T (likely a template type, e.g., int, float, or double).

: x(xPos), y(yPos)

This is an initializer list. Instead of assigning values inside the constructor body, it directly initializes the member variables x and y with the arguments xPos and yPos.

{}

The constructor body is empty because all the work (initialization) is already done in the initializer list.

A template class allows you to write a class once and use it with different data types without rewriting the code.

Microsoft Copilot

2025年11月25日星期二

Template function

A template function in C++ is a way to write a single function that works with multiple data types, avoiding code duplication.

A template allows you to define a function once and use it with different data types (like int, double, char).

It uses the keyword template followed by a type parameter inside angle brackets (<>).

In C++, the placeholder inside a template is the type parameter that represents a generic type.
It’s declared inside angle brackets (<>) after the keyword template.

A bit is the smallest unit of data in computing.

It can only have two possible values:

- 0 (off/false)

- 1 (on/true)

1 byte = 8 bits
This means a byte can represent 256 different values (from 0 to 255).

template <typename T>
int size_in_bit(T a) {
    return sizeof(a) * 8;
}

- template <typename T>
Declares a template with a placeholder type T. This allows the function to accept any data type (int, double, char, etc.).
- sizeof(a)
Returns the size of the variable a in bytes.
- * 8
Since 1 byte = 8 bits, multiplying by 8 converts the size into bits.
- Return type int
The function returns the number of bits as an integer.

int: 32 bits
double: 64 bits
char: 8 bits

Microsoft Copilot

Other than computer field

breadth: the distance or measurement from one side to the other; how broad or wide something is

cursive: ​(of handwriting) with the letters joined together

abridged: ​(of a book, play, etc.) made shorter by leaving parts out

stint: a period of time that you spend working somewhere or doing a particular activity

page: (North American English) a student who works as an assistant to a member of the US Congress

boarding house: ​a private house where people can pay for accommodation and meals

scramble: to push, fight or compete with others in order to get or to reach something

thriller: a book, play or film with an exciting story, especially one about crime or spying

capitalize on: ​to gain a further advantage for yourself from a situation

snap up: (informal) to buy or obtain something quickly because it is cheap or you want it very much

explicitly: clearly or directly, so that the meaning is easy to understand

bristle at: to suddenly become very annoyed or offended at what somebody says or does

playwright: ​a person who writes plays for the theatre, television or radio

farce: a funny play for the theatre based on silly and unlikely situations and events; this type of writing or performance

fiancée: the woman that somebody is engaged to

debutante: (especially in the past) a young, rich or upper-class woman who is going to fashionable social events for the first time

colonel: an officer of high rank in the army, the marines, or the US air force

grope: to try and find something that you cannot see, by feeling with your hands

pratfall: an embarrassing mistake

madcap: (of people, plans, etc.) crazy and not caring about danger; not sensible

shoo: to make somebody/something go away or to another place

inopportune: happening at a bad time

costar: ​one of two or more famous actors who appear together in a film or play

nail down: to reach an agreement or a decision, usually after a lot of discussion

split-second: done very quickly or very accurately

antic: very playful, funny, or silly

flirt: to behave towards somebody as if you find them sexually attractive, without seriously wanting to have a relationship with them

venture: a business project or activity, especially one that involves taking risks

prospect: a wide view of an area of land, etc.

blow off: (North American English) to deliberately not do something that you said you would

pinball: a game played on a pinball machine, in which the player sends a small metal ball up a sloping board and scores points as it bounces off objects. The player tries to prevent the ball from reaching the bottom of the machine by pressing two buttons at the side.

leaf through: to quickly turn over the pages of a book, etc. without reading them or looking at them carefully

tantalizing: making you want something that you cannot have or do

persona: ​the aspects of a person’s character that they show to other people, especially when their real character is different

pursuit: the act of looking for or trying to get something

stumble: to hit your foot against something while you are walking or running and almost fall

sprawl: to sit, lie or fall with your arms and legs spread out in a relaxed or careless way

flail around: to move around without control; to move your arms and legs around without control

kudos: the praise and honor that goes with a particular achievement or position

spontaneity: ​the quality of being spontaneous

one-time: former

clown: an entertainer who wears funny clothes and a large red nose and does silly things to make people laugh

realm: an area of activity, interest or knowledge

take aback: to shock or surprise somebody very much

curtain call: the time in the theatre when the actors come to the front of the stage at the end of a play to receive the applause of the audience

applause: the noise made by a group of people clapping their hands and sometimes shouting to show their approval or pleasure


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年11月23日星期日

Template in C++

instantiate: represent as or by an instance

Compile-time polymorphism in C++ (also called static polymorphism or early binding) is achieved mainly through function overloading and operator overloading. The compiler decides which function or operator to invoke at compile time, based on the arguments provided.

Function Overloading: Multiple functions with the same name but different parameter lists.

Operator Overloading: Redefining operators (like +, ==, etc.) to work with user-defined types.

Difference from Runtime Polymorphism: Runtime polymorphism uses virtual functions and dynamic binding, where the decision is made at execution time. Compile-time polymorphism is faster because it avoids the overhead of dynamic dispatch.

#include <iostream>
using namespace std;

void greet(string name) {   // parameter
    cout << "Hello, " << name << "!" << endl;
}

int main() {
    greet("Alice");  // argument
    greet("Bob");
    return 0;
}

In C++, a template is a feature that allows you to write generic code that works with any data type. Instead of duplicating functions or classes for different types (like int, double, or string), you can define a template once and let the compiler generate the appropriate version when needed.

In C++ templates, the angle brackets (< >) are used to specify the template arguments when instantiating a template. They tell the compiler which data type (or constant value, in case of non-type parameters) should be substituted into the generic template definition.

Microsoft Copilot

Chip

the nitty-gritty: ​the basic or most important details of an issue or a situation

transistor: a small electronic device used in computers, radios, televisions, etc. for controlling an electric current as it passes along a circuit

etch: to cut lines into a piece of glass, metal, etc. in order to make words or a picture

spec: specification: a detailed description of something, especially the design and materials needed to produce something

distributor: a person or company that supplies goods to shops, etc.

heck: used to show that you are slightly annoyed or surprised; used to emphasize something

nerd: ​a person who is boring, stupid and not fashionable

A "hippie techie" can describe someone who blends the countercultural ideals of the 1960s-70s hippie movement with modern technology, often by balancing new and old tools to foster creativity.

pal: a friend

rip: to tear something or to become torn, often suddenly or violently

paranoid: having false beliefs because of a mental illness, especially the belief that people are trying or planning to harm you


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Goggle AI overview

2025年11月13日星期四

Partnership

tamp something (down) to press something down hard, especially into a closed space

get on with something: to continue doing something, especially after you have been interrupted

service: a religious ceremony

cot: a light narrow bed that you can fold up and carry easily

soccer: DJ[ˋsɔkə]

punchy: having a strong effect because it expresses something clearly in only a few words

recount: to tell somebody about something, especially something that you have experienced

hysterics: DJ[hisˋteriks]

nemesis: punishment or defeat that is deserved and cannot be avoided

in retrospect: thinking about a past event or situation, often with a different opinion of it from the one you had at the time

haze: a mental state in which your thoughts, feelings, etc. are not clear

affectation: behavior or an action that is not natural or sincere and that is often intended to impress other people

geekiness: the quality of being knowledgeable about and obsessively interested in a particular subject, especially one that is technical or of specialist or niche interest; the quality of being unfashionable and socially inept or boringly studious

obsessive: thinking too much about one particular person or thing, in a way that is not reasonable or normal

inept: acting or done with no skill

contraption: a machine or piece of equipment that looks strange or complicated and possibly does not work well

orb: an object like a ball in shape

electrocute: to injure or kill somebody by passing electricity through their body

soldering iron: a tool that is heated and used for joining metals and wires by soldering them

assorted: ​of various different sorts

scour: to search a place or thing carefully and completely in order to find

genre: DJ[ˋʒɑ:nrə]

deserted: (of a place) with no people in it

well versed in something having a lot of knowledge about something, or skill at something

seminal: very important and having a strong influence on later developments

rhapsodize: to talk or write with great enthusiasm about something

brim: the flat edge around the bottom of a hat that sticks out

mantra: a statement or slogan that is often repeated

shorthand (for something) a shorter way of saying or referring to something, which may not be as accurate as the more complicated way of saying it

goad: something that makes somebody do something, usually by annoying them

Scotch: the type of whisky made in Scotland

throw up: vomit

pass out: to become unconscious

lounge: DJ[laundʒ]

A joint is a rolled cannabis cigarette.

LSD: a powerful illegal drug that affects people’s minds and makes them see and hear things that are not really there

decline: to refuse politely to accept or to do something

tremendous: very great

A congressional page is a high school student, typically 16 or older, who works for a member of the U.S. Senate or House of Representatives.

stint: a period of time that you spend working somewhere or doing a particular activity

sophomore: a student in the second year of a course of study at a college or university

"On my shoulders" can mean the figurative burden of great responsibility

figurative: (of language, words, phrases, etc.) used in a way that is different from the usual meaning, in order to create a particular mental picture.

round-the-clock: ​lasting or happening all day and night

pay off: (of a plan or an action, especially one that involves risk) to be successful and bring good results

adviser: a person who gives advice, especially somebody who knows a lot about a particular subject

legacy: money or property that is given to you by somebody when they die

forge something: to put a lot of effort into making something successful or strong so that it will last

embolden: to make somebody feel braver or more confident

mull over: to spend time thinking carefully about a plan or proposal


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年10月28日星期二

人不知,而不慍,不亦君子乎?

人家不了解我,我卻不怨恨,不也是君子嗎?

君子務本,本立而道生。

君子專心致力於基礎工作,基礎樹立了,「道」就會產生。

巧言令色,鮮矣仁!

花言巧語,偽善的面貌,這種人,「仁德」是不會多的。

謹而信。

寡言少語,說則誠實可信。

無友不如己者。

不要跟不如自己的人交朋友。

禮之用,和為貴。

禮的作用,以遇事都做得恰當為可貴。

恭近於禮,遠恥辱也。

態度容貌的莊矜合於禮,就不致遭受侮辱。

敏於事而慎於言。

對工作勤勞敏捷,說話卻謹慎。

不患人之不己知,患不知人也。

別人不了解我,我不急;我急的是自己不了解別人。

視其所以,觀其所由,察其所安,人焉廋哉?

考查一個人所結交的朋友;觀察他為達到一定目的所採用的方式方法;了解他的心情,安於什麼,不安於什麼。那麼,這個人怎樣隱藏得住呢?

君子周而不比。

君子是團結,而不是勾結。

知之為知之,不知為不知,是知也。

知道就是知道,不知道就是不知道,這就是聰明智慧。

人而無信,不知其可也。

作為一個人,卻不講信譽,不知那怎麼可以。

見義不為,無勇也。

眼見應該挺身而出的事情,卻袖手旁觀,這是怯懦。

君子無所爭。

君子沒有什麼可爭的事情。

君使臣以禮,臣事君以忠。

君主應該依禮來使用臣子,臣子應該忠心地服事君主。

成事不說,遂事不諫,既往不咎。

已經做了的事不再解釋了,已經完成的事不便再挽救了,已經過去的事不便再追究了。

唯仁者能好人,能惡人。

只有仁人才能夠喜愛某人,厭惡某人。

惡不仁者,其為仁矣,不使不仁者加乎其身。

厭惡不仁德的人,他行仁德只是不使不仁德的東西加在自己身上。

觀過,斯知仁矣。

仔細考察某人所犯的錯誤,就可以知道他是什麼樣式的人了。

放於利而行,多怨。

依據個人利益而行動,會招致很多的怨恨。

不患無位,患所以立。不患莫己知,求為可知也。

不發愁沒有職位,只發愁沒有任職的本領;不怕沒有人知道自己,去追求足以使別人知道自己的本領好了。

夫子之道,忠恕而已矣。

他老人家的學說,只是忠和恕罷了。

見不賢而內自省也。

看見不賢的人,便應該自己反省,有沒有和他類似的毛病。

古者言之不出,恥躬之不逮也。

古時候言語不輕易出口,就是怕自己的行動趕不上。

匿怨而友其人,左丘明恥之,丘亦恥之。

內心藏著怨恨,表面上卻同他要好,這種行為,左丘明認為可恥,我也認為可恥。

顏淵曰︰「願無伐善,無施勞。」

顏淵道︰「願意不誇耀自己的好處,不表白自己的功勞。」

已矣乎,吾未見能見其過而內自訟者也。

算了吧,我沒有看見過能夠看到自己的錯誤便自我責備的呢。

有顏回者好學,不遷怒,不貳過。

有一個叫顏回的人好學,不拿別人出氣;也不再犯同樣的過失。

人之生也直,罔之生也幸而免。

人的生存由於正直,不正直的人也可以生存,那是他僥倖地免於禍害。

仁者先難而後獲,可謂仁矣。

仁德的人付出一定的力量,然後收獲果實,可以說是仁德了。

中庸之為德也,其至矣乎!民鮮久矣。

中庸這種道德,該是最高的了,大家已經是長久地缺乏它了。

己欲立而立人,己欲達而達人。

自己要站得住,同時也使別人站得住;自己要事事行得通,同時也使別人事事行得通。

不義而富且貴,於我如浮雲。

幹不正當的事而得來的富貴,我看來好像浮雲。

多聞,擇其善者而從之;多見而識之;知之次也。

多多地聽,選擇其中好的加以接受;多多地看,全記在心裡。這樣的知,是僅次於「生而知之」的。

直而無禮則絞。

心直口快,卻不知禮,就會尖刻刺人。

人而不仁,疾之已甚,亂也。

對於不仁的人,痛恨太甚,也是一種禍害。

不在其位,不謀其政。

不居於那個職位,便不考慮它的政務。

學如不及,猶恐失之。

做學問好像生怕趕不上,還生怕丟掉了。

毋意,毋必,毋固,毋我。

不懸空揣測,不絕對肯定,不拘泥固執,不唯我獨是。

逝者如斯夫!不舍晝夜。

消逝的時光像河水一樣呀!日夜不停地流去。

知者不惑,仁者不憂,勇者不懼。

聰明人不致疑惑,仁德的人經常樂觀,勇敢的人無所畏懼。

為仁由己,而由人乎哉?

實踐仁德,全憑自己,還憑別人嗎?

內省不疚,夫何憂何懼?

自己問心無愧,那有什麼可以憂愁和恐懼的呢?

浸潤之譖,膚受之愬,不行焉,可謂明也已矣。

點滴而來,日積月累的讒言和肌膚所受、急迫切身的誣告都在你這裡行不通,那你可以說是看得明白的了。

政者,正也。子帥以正,孰敢不正?

政字的意思就是端正。您自己帶頭端正,誰敢不端正呢?

夫達也者,質直而好義,察言而觀色,慮以下人。

怎樣才是達呢?品質正直,遇事講理,善於分析別人的言語,觀察別人的容色,從思想上願意對別人退讓。

先是後得,非崇德與?攻其惡,無攻人之惡,非修慝與?一朝之忿,忘其身,以及其親,非惑與?

首先付出勞動,然後收穫,不是提高品德了嗎?批判自己的壞處,而不去批判別人的壞處,不就消除無形的怨恨了嗎?因為偶然的忿怒,便忘記自己,甚至也忘記了父母,不是糊塗嗎?

如不善而莫之違也,不幾乎一言而喪邦乎?

假若說的話不正確而也沒有人違抗,不近於一句話便喪失國家麼?

人而無恆,不可以作巫醫。

人假若沒有恆心,連巫醫都做不了。

君子和而不同。

君子用自己正確意見來糾正別人的錯誤意見,使一切都做到恰到好處,卻不肯盲從附和。

小人難事而易說也。說之雖不以道,說也;及其使人也,求備焉。

在小人底下工作很難,討他的歡善卻容易。用不正當的方式去討他的歡喜,他會歡喜的;等到他使用人的時候,便會百般挑剔,求全責備。

君子恥其言而過其行。

說得多,做得少,君子以為恥。

不患人之不己知,患其不能也。

不著急別人不知道我,只著急自己沒有能力。

以直報怨,以德報德。

拿公平正直來回報怨恨,拿恩惠來酬答恩惠。

躬自厚而薄責於人,則遠怨矣。

多責備自己,而少責備別人,怨恨自然不會來了。

小不忍,則亂大謀。

小事情不忍耐,便會敗壞大事情。

吾嘗終日不食,終夜不寢,以思,無益,不如學也。

我曾經整天不吃,整夜不睡,去想,沒有益處,不如去學習。

道不同,不相為謀。

主張不同,不互相商議。

辭達而已矣。

言辭,足以達意便罷了。

益者三友,損者三友。友直,友諒,友多聞,益矣。友便辟,友善柔,友便佞,損矣。

有益的朋友三種,有害的朋友三種。同正直的人交友,同信實的人交友,同見聞廣博的人交友,便有益了。同諂媚奉承的人交友,同當面恭維背面譭謗的人交友,同誇誇其談的人交友,便有害了。

不學禮,無以立。

不學禮,便沒有立足社會的依據。

性相近也,習相遠也。

人性情本相近,因為習染不同,便相距懸遠。

敏則有功。

勤敏就會工作效率高、貢獻大。

道聽而塗說,德之棄也。

聽到道路傳言就四處傳播,這是應該革除的作風。

子日︰「有惡︰惡稱人之惡者,惡居下流而訕上者,惡勇而無禮者,惡果敢而窒者。」

孔子憎恨一味傳播別人壞處的人,憎恨在下位而譭謗上級的人,憎恨勇敢卻不懂禮節的人,憎恨勇於貫徹自己的主張,卻頑固不通,執拗到底的人。

小人之過也必文。

小人對於錯誤一定加以掩飾。


楊伯峻《論語譯注》

2025年10月27日星期一

職場生存學

勢者,因利而制權也。

所謂勢,就是根據於己有利的原則而採取臨機應變的作戰行動。

不戰而屈人之兵,善之善者也。

不經過交戰而能使敵人屈服,才算是高明中的最高明。

不若則能避之。

實力不如敵人,就要避免決戰。

善守者,藏於九地之下。

善於防守的人,隱藏自己的兵力就像藏在地下,深不可見。

奇正之變,不可勝窮也。

奇正的錯綜變化,卻是無窮無盡。

故善戰者,求之於勢,不責於人,故能擇人而任勢。

所以,善於指揮作戰的將帥,總是設法尋求有利的態勢,不強求自己的部屬,這樣他們的注意力就能不放在強求人上,而放在充分利用有利的態勢上。

兵之勝,避實而擊虛。

作戰取得勝利,是由於避開敵人實處而攻擊敵人的虛處。

無邀正正之旗,勿擊堂堂之陳,此治變者也。

不要去攔截那種旗幟整齊、陣形嚴密的敵軍,不要去攻擊那種陣容盛大、實力雄厚的敵軍,這是掌握戰術變化的方法。

故用兵之法,無恃其不來,恃吾有以待也。

所以用兵的法則是,不要指望敵人不來,而要依靠自己作好準備,嚴陣以待。

廉潔,可辱也。

自愛廉潔,就可能受不了敵人污辱而落入圈套。

兵非多益,惟無武進,足以併力、料敵、取人而已。

打勝仗不在於兵力越多越好,只要不是輕敵貿進,能集中兵力、判明敵情、取得人心就足夠了。

主不可以怒而興師,將不可以慍而致戰。

國君不可因一時惱怒而發動戰爭,將帥不可因一時氣憤而進行戰爭。


吳仁傑《新譯孫子讀本》

Chapter Quiz

In C++, a member function is simply a function that belongs to a class (or struct). It operates on objects of that class and has access to the class’s data members (including private ones).

The -> is called the arrow operator in C++. It’s used when you have a pointer to an object (or struct) and you want to access one of its members (a variable or a function).

The dot operator (.) in C++ is called the direct member access operator. It’s used to access data members (variables) and member functions (methods) of an object, structure, or union directly.

In C++, an object is an instance of a class.

Think of it this way:

  • A class is like a blueprint (it defines attributes and behaviors).
  • An object is the real thing created from that blueprint.
Using "this" inside constructor:

ComplexNumber(float real, float im){
 this->real_part = real;
 this->im_part = im;
}

An include guard in C++ is a technique used in header files to prevent the same file from being included multiple times during compilation. Without it, if a header is included more than once (directly or indirectly), you’ll get redefinition errors because classes, functions, or variables would be declared multiple times.

#ifndef HEADER_FILE_NAME   // If not defined yet
#define HEADER_FILE_NAME   // Define it now

// Your header file content goes here
class MyClass {
public:
    void hello();
};

#endif // HEADER_FILE_NAME

#ifndef MYCLASS_H
#define MYCLASS_H

class MyClass {
public:
    void greet();
};

#endif

#pragma once is a preprocessor directive in C++ that tells the compiler to include a header file only once per compilation, no matter how many times it’s referenced.

It serves the same purpose as traditional include guards (#ifndef … #define … #endif), but it’s shorter and less error‑prone.

parse something: to divide a sentence into parts and describe the grammar of each word or part

Operator overloading in C++ is a way to give special meaning to operators (like +, -, ==, [], etc.) when they are used with user‑defined types (classes or structs). It’s a form of compile‑time polymorphism that makes objects behave more like built‑in types.

When you define a member function outside the class, you use the scope resolution operator to tell the compiler which class the function belongs to.

A global function is defined outside of any class. If there’s a naming conflict (e.g., a local variable or function with the same name), you can use the global scope resolution operator (::) to explicitly call the global version.

Microsoft Copilot

something basic

"Hello, World!\n"; → A string literal. The \n is an escape sequence that inserts a newline after printing.

#include <iostream>
using namespace std;   // brings all names from std into scope

int main() {
    cout << "Hello" << endl;       // works because of 'using namespace std;'
    std::cout << "World" << std::endl; // also works, fully qualified
    return 0;
}

2025年10月25日星期六

Death of his friend

"Retreat into myself" means to withdraw from the outside world to focus on your inner thoughts, feelings, and well-being, often for reflection and recharging.

recollection: memory

wash over somebody: (of a feeling) to suddenly affect somebody strongly, so that they are not aware of anything else

frantic: done quickly and with a lot of activity, but in a way that is not very well organized

schemer: a person who plans secretly to do something for their own advantage

entrepreneur: DJ[͵ɔntrəprəˋnə:]

accomplished: very good at a particular thing; having a lot of skills

ungainly: moving in a way that is not smooth or attractive

spindly: very long and thin and not strong

contained: calm and controlled, and not showing a lot of emotion or trying to attract attention

goofy: silly; stupid

glimpse: a sight of somebody/something for a very short time, when you do not see the person or thing completely

sob: to cry noisily, taking sudden, sharp breaths

marooned: left in a place from which you cannot escape

cork: a light, soft material that is the thick bark of a type of Mediterranean oak tree

chute: a tube or passage down which people or things can slide

avalanche: a mass of snow, ice and rock that falls down the side of a mountain

To "careen down" means to move forward quickly while swaying or lurching from side to side, often in an uncontrolled or reckless manner.

lurch: to make a sudden, unsteady movement forward or to one side

stumble: to walk or move in an unsteady way

tumble: to fall downwards, often hitting the ground several times, but usually without serious injury; to make somebody/something fall in this way

igloo: a small round house or shelter built from blocks of hard snow by the Inuit people of northern North America and Greenland

gung-ho: too enthusiastic about something, without thinking seriously about it, especially about fighting and war

peril: serious danger

harbor something to keep feelings or thoughts, especially negative ones, in your mind for a long time

overland: across the land; by land, not by sea or by air

ranger: a person whose job is to take care of a park, a forest or an area of countryside

profound: very great; felt or experienced very strongly


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

dictionary.cambridge.org

2025年10月22日星期三

Constructor

public:
    Person(const std::string& name, float energy, float happiness, float health)
        : name(name), energy(energy), happiness(happiness), health(health) {}

parameterized constructor with a member initializer list

Person(...) → Constructor for the Person class.

const std::string& name → Passes the string by reference (avoids copying) and const ensures it won’t be modified inside the constructor.

A reference is an alias for another variable. 

float energy, float happiness, float health → Parameters to initialize the object’s state.

: name(name), energy(energy), happiness(happiness), health(health) → This is the member initializer list.

It directly initializes the data members with the values passed in.

More efficient than assigning inside the constructor body, especially for complex types like std::string.

{} → Empty body, since all initialization is already done in the initializer list.

Microsoft Copilot

2025年10月21日星期二

glacier

freak: (informal) a person with a very strong interest in a particular subject

outcrop: a large mass of rock that stands above the surface of the ground

lexicon: (linguistics) all the words and phrases used in a particular language or subject; all the words and phrases used and known by a particular person or group of people

crag: a high, steep, rough mass of rock

crux: the most important or difficult part of a problem or an issue

belay: (specialist) (in climbing) to attach a rope to a rock, etc.; to make a person safe while climbing by attaching a rope to the person and to a rock, etc.

bivouac: a temporary camp or shelter, without a tent, that is made and used especially by people climbing mountains or by soldiers

branch out: to start to do an activity that you have not done before, especially in your work or business

iron out: to get rid of any problems or difficulties that are affecting something

stipend: an amount of money that is paid regularly to somebody, especially a priest, as wages or money to live on

glaciated: covered or having been covered by glaciers or ice sheets.

glacier: a slow-moving mass or river of ice, formed from snow on mountains or near the North Pole or South Pole

careen: to move forward very quickly especially in a way that is dangerous or shows a loss of control

mumble: to speak or say something in a quiet voice in a way that is not clear

weird: DJ[wiəd]


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年10月20日星期一

Edema and CCBs

Lower limb edema is one of the most common side effects of calcium channel blockers (CCBs), especially the dihydropyridine group like Amlodipine. CCBs dilate arterioles but not venules. This imbalance raises capillary hydrostatic pressure, pushing fluid into surrounding tissues. As a result, fluid accumulates in the interstitial space, most noticeably in the ankles and lower legs. Risk factors include older age, female sex and warm weather.

Summarized from Microsoft Copilot (GPT-5)

Inheritance and Polymorphism

modular: (of machines, buildings, etc.) consisting of separate parts or units that can be joined together

Inheritance in C++ is one of the core pillars of Object-Oriented Programming (OOP). It allows you to create new classes (called derived classes) based on existing ones (called base classes). This helps you reuse code, establish relationships between classes, and extend functionality without rewriting everything from scratch.

attribute: a quality or feature of somebody/something

In C++, a data member is simply a variable that belongs to a class. It represents the attributes or properties of the objects created from that class.

A member function in C++ is a function that belongs to a class. It defines the behavior of the objects created from that class, while data members define the state (attributes).

ammo: ammunition (= a supply of bullets, etc. to be fired from guns)

hindsight: the understanding that you have of a situation only after it has happened and that means you would have done things in a different way

In C++, the phrase virtual void is used when declaring a virtual function that returns nothing (void).

Virtual functions are a cornerstone of runtime polymorphism—they allow the program to decide at runtime which version of a function to call, depending on the actual type of the object being pointed to, not just the type of the pointer.

Declared in a base class using the keyword virtual.

Can be overridden in a derived class.

Enable dynamic dispatch (late binding).

If a class has virtual functions, its destructor should also be virtual to ensure proper cleanup when deleting derived objects through base pointers.

A destructor in C++ is a special member function of a class that is automatically called when an object goes out of scope or is explicitly deleted. Its main purpose is to release resources (like memory, file handles, or network connections) that the object may have acquired during its lifetime.

In C++, a protected member is a class member (data or function) that sits in between private and public in terms of accessibility.

Accessible inside the class where it is defined.

Accessible in derived (child) classes.

NOT accessible from outside the class hierarchy (unlike public).

So, protected is mainly useful when you want to hide details from the outside world but still allow subclasses to use or extend them.

Polymorphism in C++ is one of the most powerful features of Object-Oriented Programming (OOP). The word literally means “many forms”, and in programming it allows the same function, operator, or method name to behave differently depending on the context.

Function overloading allows multiple functions with the same name but different parameter lists within the same scope.

Function overriding allows a derived class to provide a specific implementation of a method already defined in its base class.

A parameter list appears inside the parentheses of a function declaration or definition.

void greet(string name, int age);

Parameter Type: Specifies the data type (string, int, etc.)

Parameter Name: Variable name used inside the function (name, age)

In C++, access specifiers determine the visibility and accessibility of class members (variables and functions). They are essential for implementing encapsulation — one of the core principles of object-oriented programming.

Types of access specifiers in C++ include Public, Private and Protected.

A virtual function is a member function in a base class that you expect to override in derived classes. It’s declared using the virtual keyword.

In C++, const override is used when a virtual function in a derived class overrides a const virtual function from a base class. It ensures both const correctness and runtime polymorphism.

In C++, polymorphism and pointers work together to enable runtime polymorphism, allowing you to call derived class methods through base class pointers. This is a powerful feature of object-oriented programming that supports flexible and extensible code design.

instance: a particular example or case of something

The declaration std::vector<Item*> inventory; in C++ defines a dynamic array of pointers to Item objects.

inventory: The name of the vector.

inventory is a container that holds pointers to Item objects, not the objects themselves.

An abstract class in C++ is a class that serves as a blueprint for other classes but cannot be instantiated directly. It’s mainly used to define a common interface for derived classes.

An abstract class is created when at least one pure virtual function is declared.

A pure virtual function is a virtual function with = 0 at the end of its declaration.

You cannot create objects of an abstract class, but you can use pointers or references to it.

Any class that inherits from an abstract class must implement all pure virtual functions, otherwise it also becomes abstract.

A pure virtual class in C++ is essentially the same as an abstract class—it’s a class that contains at least one pure virtual function. Such a class cannot be instantiated directly and is meant to serve as a base class for other classes to implement specific behavior.

Inheritance is the mechanism by which one class (child/derived) acquires properties and behaviors of another class (parent/base). It promotes code reusability and establishes a relationship between classes. 

class A {

public:

    void greet() {

        cout << "Hello from A!" << endl;

    }

};


class B : public A {

    // B inherits greet() from A

};

Polymorphism allows objects of different classes to be treated as objects of a common base class, typically through virtual functions. It enables flexibility and dynamic behavior.

class Base {

public:

    virtual void show() {

        cout << "Base class" << endl;

    }

};


class Derived : public Base {

public:

    void show() override {

        cout << "Derived class" << endl;

    }

};


Base* ptr = new Derived();

ptr->show();  // Outputs: Derived class

Base* ptr: Declares a pointer to the base class Base.

new Derived(): Creates an object of the derived class Derived.

ptr->show(): Calls the show() method using the base class pointer


Microsoft Copilot

The Real World

Now-defunct: no longer existing, operating, or functioning

the bowels of something [plural] (literary) the part that is deepest inside something

trip up: to make a mistake; to deliberately make somebody do this

deliberately: done in a way that was planned, not by chance

mantra: a statement or slogan that is often repeated

prototype: the first design of something from which other forms are copied or developed

meld: to combine with something else; to make something combine with something else

cobble together: to produce something quickly and without great care or effort, so that it can be used but is not perfect

entice: to persuade somebody/something to go somewhere or to do something, usually by offering them something

pitch: talk or arguments used by a person trying to sell something or persuade people to do something

tout: to try to persuade people to buy your goods or services, especially by going to them and asking them directly

flyer: a small sheet of paper that advertises a product or an event and is given to a large number of people


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年10月14日星期二

Operator Overloading

In C++, operator overloading lets you redefine how operators (like +, -, [], ==, etc.) behave when used with user-defined types (classes/structs). It’s a form of compile-time polymorphism, making objects act more like built-in types.

In C++, the return type of a function (or operator overload) specifies what kind of value the function gives back to the caller.

The caller is simply the function that initiates a call to another function. The callee is the one being executed as a result.

In C++ (and C), when we talk about the left-hand side operand (LHS operand), we usually mean the expression that appears to the left of an assignment operator (=).

In C++, a prototype usually refers to a function prototype. It’s essentially a declaration of a function that tells the compiler the function’s name, the return type, the number and types of parameters, but it does not include the function body (implementation).

std::string& item means:
"item is a reference to an existing std::string object."

alias: (computing) a name that can be used instead of the actual name for a file, internet address, etc.

int x = 10;

int& ref = x;   // ref is another name for x

ref = 20;       // changes x to 20


In C++, void is a special keyword that essentially means “no type”.

If a function doesn’t return a value, you declare it with void:

void greet() {

    std::cout << "Hello!" << std::endl;

    // no return statement needed

}

Here, greet() performs an action but doesn’t give back a result.


In C++, the expression return *this; is very common inside class member functions.

class Number {

    int value;

public:

    Number(int v=0) : value(v) {}

    Number& operator=(const Number& other) {

        value = other.value;

        return *this;   // return the current object by reference

    }

};

Microsoft Copilot

Exposure Value

Why we have to change the exposure value rather than changing the aperture size, shutter speed or ISO?

This is a subtle but important distinction in photography.

The Exposure Triangle

- Aperture: Controls light intake and depth of field (background blur vs. sharpness).

- Shutter Speed: Controls exposure time and motion blur (freeze vs. streak).

- ISO: Controls sensor sensitivity and image noise.

Changing any of these affects not just brightness, but also the look of your photo.


What Exposure Value (EV Compensation) Does

Exposure Value (EV compensation) is not a fourth setting—it’s a way of telling the camera:

“Make this scene brighter or darker than your meter thinks it should be, but keep my chosen aperture/shutter/ISO priorities intact.”

- In Aperture Priority mode: you lock aperture, the camera adjusts shutter speed. EV shifts brightness without touching your chosen aperture.

- In Shutter Priority mode: you lock shutter speed, the camera adjusts aperture. EV shifts brightness without touching your chosen shutter.

- In Auto ISO setups: EV can nudge brightness without you manually juggling ISO.


 Why Use EV Instead of Aperture/Shutter/ISO?

- Preserve creative intent

- Speed and convenience

- EV is a quick dial adjustment, especially useful in fast-changing light (e.g., clouds, stage lighting).

- Fine-tuning exposure

- Sometimes the camera’s meter is “fooled” (e.g., snow scenes look too dark, backlit subjects look too bright). EV lets you correct this instantly.

- Avoiding side effects

- Changing ISO adds noise.

- Changing aperture alters depth of field.

- Changing shutter speed alters motion blur.

EV lets you adjust brightness without those trade-offs.


When to Change Aperture, Shutter, or ISO Directly

- If you want to change the artistic look (blur, sharpness, motion, grain).

- If you’re in Manual Mode—EV doesn’t apply, you directly balance the triangle yourself.


 In short:

You use EV compensation when you want to adjust exposure brightness without sacrificing your chosen creative settings. You change aperture, shutter, or ISO when you want to change the visual style of the photo itself.


Microsoft Copilot

Photos with description

bedrock: a strong base for something, especially the facts or the principles on which it is based

dub: to give somebody/something a particular name, often in a humorous or critical way

frenetic: involving a lot of energy and activity in a way that is not organized

artifact: an object that is made by a person, especially something of historical or cultural interest

aspiration: a strong desire to have or do something

vogue: a fashion for something

astronaut: DJ[ˋæstrənɔ:t]

cottage: a small house, especially in the country

wrangler: a cowboy or a cowgirl, especially one who takes care of horses

preside: to lead or be in charge of a meeting, ceremony, etc.

dexterity: skill in using your hands or your mind

reminisce: DJ[͵remiˋnis]

cub: a branch of the Scout Association for boys and girls between the ages of 8 and 10 or 11

mecca: a place that many people like to visit, especially for a particular reason

rugged: (of the landscape) not level or smooth and having rocks rather than plants or trees

ford: to walk or drive across a river or stream

sophomore: a student in the second year of a course of study at a college or university


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年10月12日星期日

Source Files

In C++ development, especially when using Visual Studio Code (VS Code), the tasks.json file plays a crucial role in automating the build process.

If you're writing pure C++ code, using .hpp can make your intent clearer.

If you're working in a mixed C/C++ environment, .h might be more compatible.

In Visual Studio Code (VS Code), the .hpp file extension is used for C++ header files

#pragma once is a preprocessor directive in C++ that ensures a header file is included only once during compilation.

In C++, the #ifndef and #define directives are part of include guards, which prevent a header file from being included multiple times during compilation. This is crucial for avoiding redefinition errors.

In C++, a macro name is an identifier used with preprocessor directives like #define, #ifdef, and #ifndef.

#endif is a preprocessor directive in C++ that marks the end of a conditional block started by #if, #ifdef, or #ifndef. It's most commonly used in include guards to prevent multiple inclusions of a header file

In C++, public function prototypes refer to the declarations of member functions that are accessible from outside the class. These are typically placed in the public section of a class definition, often inside a header file (.hpp or .h)

In C++, private data member declarations are used to define variables inside a class that are not accessible directly from outside the class. This is a key part of encapsulation, one of the core principles of object-oriented programming.

The scope resolution operator in C++ is written as :: and is used to access identifiers (like variables, functions, or classes) that are defined in a specific scope—such as a namespace or class.

Microsoft Copilot

2025年10月8日星期三

header and implementation files

Header files contain declarations — they tell the compiler what functions, classes, and variables exist, but not how they work.

Implementation files contain the definitions — the actual code that performs the work declared in the header.

A compiler toolchain in C++ refers to the complete set of tools used to transform source code into executable programs.

Assembly language is a low-level programming language that provides direct control over a computer's hardware. It's one step above machine code and uses mnemonics (human-readable instructions) to represent processor operations.

In C++, an object file is an intermediate binary file generated during the compilation process. It contains machine code and metadata, but it's not executable on its own — it must be linked with other object files and libraries to create a final executable.

hassle: a situation that is annoying because it involves doing something difficult or complicated that needs a lot of effort

In C++, I/O streams (Input/Output streams) are a powerful abstraction for reading and writing data. They are part of the library and allow you to interact with the console, files, and other data sources in a consistent way

In C++, a linker is a crucial tool that combines multiple object files into a single executable or library. It resolves references between functions and variables across different files, ensuring that your program runs as a unified whole.

An IDE (Integrated Development Environment) is a software application that provides comprehensive tools for software development in one place. For C++ programming, IDEs streamline coding, compiling, debugging, and project management.

Microsoft Copilot

Lakeside School Schedule

surefire: certain to be successful or to happen as you expect

thespian: an actor

fixated (on somebody/something) always thinking and talking about somebody/something in a way that is not reasonable

slumber: to sleep

crampon: a metal plate with pointed pieces of metal on the bottom, worn on somebody’s shoes when they are walking or climbing on ice and snow

undaunted: still enthusiastic and determined, despite difficulties, danger, etc.

unabashed: not ashamed, embarrassed or affected by people’s negative opinions, when other people would be

glint: a sudden flash of light or color shining from a bright surface

Herculean: needing a lot of strength, determination or effort

permutation: any of the different ways in which a set of things can be ordered

sledding: the activity of riding on a sled

sled: a vehicle for travelling over snow and ice, with long narrow pieces of wood or metal instead of wheels. Larger sleds are pulled by horses or dogs and smaller ones are used for going down hills as a sport or for pleasure.

hole up: (informal) to hide in a place

guru: (informal) a person who is an expert on a particular subject or who is very good at doing something

A teletype is an electromechanical device that sends and receives typed messages over communications channels like telephone lines, telegraphs, or radio waves. Historically, teletypes were used for sending telegrams or as computer input/output devices.

assassination: DJ[ə͵sæsiˋneiʃən]

shellshocked: shocked, confused or anxious because of a difficult situation, and unable to think or act normally

cocoon: to protect somebody/something by surrounding them or it completely with something

self-imposed: a self-imposed task, duty, etc. is one that you force yourself to do rather than one that somebody else forces you to do

cobble together: to produce something quickly and without great care or effort, so that it can be used but is not perfect


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年9月30日星期二

Using classes

Inventory myInventory(5);

Inventory → the name of a class (or struct) you’ve defined earlier.

myInventory → the name of the object (an instance of the class).

(5) → this calls a constructor of the class Inventory that takes an int parameter.

So this line means:

“Create an object called myInventory of type Inventory, and initialize it using the constructor that accepts the integer 5.”

myInventory.addItem("Arrow");

myInventory is an object of some class, say Inventory.
addItem() is a member function of that class.
"Arrow" is a string literal being passed as an argument.
So in C++, you’d typically define a class Inventory that stores items (maybe in a std::vector<std::string>), and then implement addItem() to push new items into that container.

The dot (.) operator is one of the most fundamental symbols in many programming languages, including C, C++, Java, and C#. Its main purpose is to access members (variables, methods, or properties) of an object, structure, or namespace.

When you create an object of a class, you use the dot operator to call its methods or access its fields.

In programming, when we say “call a method”, we mean asking the computer to run the block of code defined inside that method.

A method (or function) is a reusable block of code that performs a specific task.

To call a method is to execute it: the program jumps to that method, runs its instructions, and then comes back to continue where it left off.

Microsoft Copilot

The power of quiet

rant: to speak or complain about something in a loud and/or angry way

what the heck: (informal) used to say that you are going to do something that you know you should not do

struck: strike past tense

unjust: not deserved or fair

ire: anger

stern: serious and often showing that you do not approve of somebody/something; expecting somebody to obey you

affiliate: a company, an organization, etc. that is connected with or controlled by another, larger one

accuse: to say that somebody has done something wrong or is guilty of something

larceny: the crime of stealing something from somebody; an occasion when this takes place

renege: to break a promise, an agreement, etc.

implicit (in something) suggested without being directly expressed

stipulate: to state clearly and definitely that something must be done, or how it must be done

tiff: a slight argument between close friends or two people who love each other

rack up: to collect something, such as profits or losses in a business, or points in a competition

dive in: (informal) to start doing something without hesitating or with enthusiasm

paycheck: the cheque that you are given when your salary or wages are paid to you

pitch: to aim or direct a product or service at a particular group of people

tedious: lasting or taking too long and not interesting

balk (at something) to be unwilling to do something or become involved in something because it is difficult, dangerous, etc.

slot: to put something into a space that is available or designed for it; to fit into such a space

underway: having started

overwhelm: DJ[͵əuvəˋhwelm]

if something happens several times in a row, it happens in exactly the same way each time, and nothing different happens in the time between

bastion: (formal) a group of people or a system that protects a way of life or a belief when it seems that it may disappear

insular: (disapproving) only interested in your own country, ideas, etc. and not in those from outside

coed: a female student at a co-educational school or college

bemoan: bemoan something to complain or say that you are not happy about something

insinuate: to slowly move yourself or a part of your body into a particular position or place

draw up: to make or write something that needs careful thought or planning

geeky: very knowledgeable about and interested in a particular subject, especially one that is technical or of specialist or niche interest; unfashionable and lacking social skills or boringly studious

squeaky: making a short, high sound

antihero: the main character in a story, but one who does not have the qualities of a typical hero, and is either more like an ordinary person or morally bad

wannabe: a person who behaves, dresses, etc. like somebody famous because they want to be like them

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年9月28日星期日

Constructors and Destructors

A constructor is a special member function of a class that is automatically called when an object is created. Its purpose is to initialize the object.

A destructor is a special member function that is automatically called when an object goes out of scope or is deleted. Its purpose is to clean up resources.

In programming, overloaded refers to a feature where multiple functions or operators share the same name but differ in their parameters or behavior.

Function Overloading
This allows you to define multiple versions of a function with the same name but different:
- Number of parameters
- Types of parameters
- Order of parameters

Operator Overloading
This lets you redefine how operators (like +, -, ==) behave for user-defined types (classes).

An implicit constructor in C++ refers to a constructor that the compiler automatically provides or uses without you explicitly defining it.

explicit: (of a statement or piece of writing) clear and easy to understand, so that you have no doubt what is meant

Heap memory is a region of memory used for dynamic allocation—you manually request and release memory during runtime using pointers.

void greet(string name) {
    cout << "Hello, " << name << "!" << endl;
}

Here, name is a parameter of the greet function.

void greet(string name) {  // 'name' is a parameter
    cout << "Hello, " << name << "!" << endl;
}

int main() {
    greet("Alice");        // "Alice" is the argument
}

Object instantiation in C++ refers to the process of creating an instance of a class—in other words, making an actual object that you can use in your program.

A default constructor in C++ is a constructor that takes no parameters (or all parameters have default values). It's automatically called when an object is created without any arguments.

In C++, new and delete are operators used for dynamic memory management—they allow you to allocate and deallocate memory on the heap manually.

In C++, this is a keyword that refers to the pointer to the current object—the instance of the class where the member function is being executed.

class Person {
private:
    string name;

public:
    void setName(string name) {
        this->name = name;  // Resolves ambiguity between parameter and member
    }

    void greet() {
        cout << "Hello, " << this->name << "!" << endl;
    }
};

Parameter is a variable passed into a function or constructor to provide input.
Member is a variable declared inside a class to represent the state of an object.

In C++, a member initializer list is a special syntax used in constructors to directly initialize class members before the constructor body runs. It's more efficient and often necessary for certain types of members.

In C++, an overloaded constructor means defining multiple constructors within the same class, each with different parameter lists. This allows objects to be created in various ways depending on the arguments provided.

// overloaded constructor 
Inventory(int capacity_i) : capacity(capacity_i) {
    items = new std::vector<std::string>();
}

Inventory(int capacity_i) is a constructor for the Inventory class.

: capacity(capacity_i) is the member initializer list, which directly initializes the member capacity with the value of capacity_i.

Inside the constructor body, items is dynamically allocated as a new std::vector on the heap.

In C++, the ~ symbol is used to define a destructor, which is a special member function that is automatically called when an object is destroyed.

Microsoft Copilot

2025年9月24日星期三

scandal

rift: ​a serious break in the relationship between people or organizations

in retrospect: thinking about a past event or situation, often with a different opinion of it from the one you had at the time

ebb: a point or condition of decline

absorbed: very interested in something/somebody so that you are not paying attention to anything else

spool: a round object around which you wind such things as thread, wire or film; a reel together with the film, wire, thread, etc. that is wound around it

canister: a flat, round metal container used for storing film

fire sale: a sale at low prices of things that a company or person owns, usually in order to pay debts

scour: ​to search a place or thing carefully and completely in order to find

Dumpster: a large open container for putting old bricks, rubbish, etc. in. The Dumpster is then loaded on a lorry and taken away.

grime: dirt that forms a layer on the surface of something

squabble: to argue noisily about something that is not very important

smear: to make something dirty or greasy

yank: to pull something/somebody hard, quickly and suddenly

stash: to store something in a safe or secret place

glee: a feeling of happiness, usually because something good has happened to you, or something bad has happened to somebody else

abscond with: to leave secretly and take with you something, especially money, that does not belong to you

go ballistic: ​(informal) to become very angry

a litany of: (formal) a long boring account of a series of events, reasons, etc.

grievance: something that you think is unfair and that you complain or protest about; a feeling that you have been badly treated

falsehood: the state of not being true; the act of telling a lie

head off: prevent, block

bequeath: to say in a will that you want somebody to have your property, money, etc. after you die

Treasury: (in the UK, the US and some other countries) the government department that controls public money


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

2025年9月23日星期二

腹式呼吸

Diaphragmatic breathing, often seen during NREM sleep, refers to the use of slow, deep breaths that engage the diaphragm. It's different from the shallow, chest-focused breathing often seen during REM sleep. Diaphragmatic breathing involves expanding the abdomen to fully utilize the lungs' capacity and can help to regulate the autonomic nervous system, potentially reducing stress and improving respiratory and cardiovascular function.

Google AI overview and edited

iOS 26

Is it a good idea to upgrade my iPhone SE2 to iOS 26? Is it a good idea to postpone the upgrade after Apple finding more bugs? Will the battery be used up faster when I upgrade my iPhone SE2 to iOS26?

Upgrading can be fine, but you should be prepared: expect a short-term battery and heat hit right after installing, some early users report bugs on day‑one builds, and many experts recommend waiting for the 26.0.1/26.1 patch if your iPhone is critical for work or travel.

Immediately after a major iOS update your iPhone will do background work (indexing, model downloads, app updates) that commonly causes higher battery drain and warmer operation for 24–72 hours; Apple says this is normal and usually temporary.

When Apple says your iPhone is “indexing,” it’s essentially re‑organizing and cataloging your data in the background so the system can find things quickly later. Think of it like a librarian going through every book in a library, tagging and shelving them so you can instantly find what you need

Over the longer term, new features that demand more resources can produce a measurable, ongoing battery impact for some users, depending on how heavily you use those features.

Microsoft Copilot

Act like a business man

blazer: a jacket, not worn with matching trousers, often showing the colors or badge of a club, school, team, etc.

nonchalance: a calm and relaxed way of behaving; behavior that gives the impression you are not feeling worried

pore over: to look at or read something very carefully

upscale: in a way that involves buying or selling goods and services that are expensive and of high quality

go belly up: (informal) to fail completely

scrawl: to write something in a careless untidy way, making it difficult to read

broach: to begin talking about a subject that is difficult to discuss, especially because it is embarrassing or because people disagree about it

hotshot: a person who is extremely successful in their career or at a particular sport

proponent: a person who supports an idea or course of action

addendum: ​a section of extra information that is added to something, especially to a book

obligation: something which you must do because you have promised, because of a law, etc.

stipulate: specify

giddily: dizzily

rehash: to arrange ideas, pieces of writing or pieces of film into a new form but without any great change or improvement

miffed: slightly angry or upset

scramble: to get or gather something with difficulty or in irregular ways


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

2025年9月22日星期一

Similarity of atomic world and solar system

Atom (Bohr model):
- Dense central nucleus (protons + neutrons).
- Electrons orbit around it in shells.

Solar System:
- Massive central Sun.
- Planets orbit around it in paths.

Atom: Held together by electromagnetic force (negative electrons attracted to positive nucleus).
Solar System: Held together by gravity (planets attracted to the Sun’s mass).
Both forces follow an inverse-square law (strength decreases with the square of distance).

However, electrons don’t move in neat circular orbits like planets. Instead, quantum mechanics tells us they exist in probability clouds, not fixed paths. If atoms really behaved like tiny solar systems, they would collapse quickly due to radiation loss. Quantum rules prevent that.

In classical electrodynamics, an electron orbiting a nucleus is an accelerating charge. Accelerating charges must emit electromagnetic radiation, losing energy continuously. That would make the electron spiral into the nucleus in about 10⁻¹¹ seconds --- atoms would collapse, and matter as we know it couldn’t exist.

Acceleration isn’t just about speeding up or slowing down. In physics, acceleration means any change in velocity, and velocity includes both speed and direction. So, even if an electron were moving at a constant speed around the nucleus, it would still be constantly changing direction. That change in direction means it has a centripetal acceleration toward the nucleus.

Quantum mechanics says electrons can only occupy discrete energy states. They cannot radiate energy continuously; they can only “jump” between levels, emitting or absorbing photons of specific energies. In the lowest state (the ground state), there’s no lower level to fall into, so no radiation is emitted.

Microsoft Copilot

悶熱

為什麼颱風吹襲前通常會比較悶熱?

颱風中心附近有強烈的上升氣流,空氣被抽升到高空後,會在颱風外圍下沉。這些下沉氣流在壓縮過程中會升溫,使受影響地區天氣晴朗炎熱。下沉氣流會驅散雲層,使天空變得晴朗,陽光更容易直射地面,進一步推高氣溫。在颱風還沒靠近時,當地風勢通常不大,空氣流動減弱,熱氣和濕氣容易積聚,讓人感覺悶焗。在北半球,颱風環流是逆時針的。如果颱風在華南以東,香港常會吹偏北風,把內陸的熱空氣帶過來,加劇悶熱感。

Microsoft Copilot

2025年9月21日星期日

Function members

Keeping data as private as possible in C++ is a cornerstone of good object-oriented design.

Encapsulation means bundling data with the methods that operate on it.

By making data private, you ensure that it can only be accessed or modified through controlled interfaces (public methods).

This protects the internal state of an object from unintended interference.

Private members prevent external code from directly changing critical values.

In C++, setters and getters are public member functions used to access and modify private data members of a class. They’re essential for encapsulation, which protects internal data and provides controlled access

Getter (Accessor): Retrieves the value of a private member.
Setter (Mutator): Updates the value of a private member.

The concept of a vector spans across mathematics, physics, and computer science --- but each field gives it a slightly different flavor.

In Mathematics, a vector is a quantity with both magnitude and direction.

In Physics, vectors describe physical quantities that require direction and magnitude. Velocity, acceleration, force, momentum are common examples.

In computing, a vector often refers to a dynamic array --- a resizable list of elements.
Example in C++: std::vector<int> nums = {1, 2, 3};

The arrow operator (->) in C++ is used to access members of a structure or class through a pointer. It’s a shorthand for dereferencing a pointer and then accessing a member.

std::string&: passes the string by reference, avoiding a copy.

Together, const std::string& is the best practice for passing large objects efficiently and safely.

In C++, the std::find() function is part of the Standard Template Library (STL) and is used to search for a specific value within a range of elements. It’s defined in the <algorithm> header and works with containers like arrays, vectors, lists, and more.

std::find(start_iterator, end_iterator, value);

start_iterator: Beginning of the range.
end_iterator: One past the last element of the range.
value: The value to search for.

The != operator in C++ means "not equal to". It's a relational operator used to compare two values. If the values are not equal, it returns true; otherwise, it returns false.

items->end() returns an iterator that points one past the last element of the container. It does not point to a valid element. It’s a sentinel used to mark the end of a range.

In C++, the const qualifier is a powerful tool that tells the compiler: “This value should not be changed.” It’s all about protecting data and clarifying intent.

Constant correctness in C++ is the discipline of using the const keyword wherever possible to ensure that data which shouldn't be modified—isn't. It’s not just a style preference; it’s a powerful way to catch bugs early, clarify intent, and make your code safer and more maintainable.

It means, “Everything that isn’t supposed to change should be marked as const.”

In C++, && can be used as logical AND operator:

int a = 5, b = 10;
if (a > 0 && b > a) {
    std::cout << "Both conditions are true!" << std::endl;
}

tweak: to make slight changes to a machine, system, etc. to improve it

for (initialization; condition; update) {
    // code to execute
}

Microsoft Copilot