搜尋此網誌

2025年8月17日星期日

Functions in C++

Modularity refers to the degree to which a system's components can be separated and recombined, often for increased flexibility and variety of use. It's a concept that can be applied across various disciplines, including engineering, computer science, and biology.

A simple example of a function in C++ that returns a value:

#include <iostream>

using namespace std;

int multiply(int x, int y) {

    return x * y;

}

int main() {

    int result = multiply(4, 5);

    cout << "The result is: " << result << endl;  // Output: The result is: 20

    return 0;

}

A function is a reusable block of code that performs a specific task. It can take inputs (parameters), do something, and optionally return a value.

Parameter: a variable in the function definition that receives a value

Argument: the actual value passed to the function when it is called

Use const in parameters when you don’t want them modified

A global function is defined outside of any class and can be accessed from anywhere in the file (or other files if declared properly).

Functions defined inside a class are called member functions. They operate on the data members of the class and can be either public or private.

In C++, a function signature is the part of a function declaration that includes the function name and the parameter types (but not the return type or parameter names).

In C++, the return type of a function specifies the type of value that the function will send back to the caller when it finishes executing.

What Is a Return Type?
It’s the data type declared before the function name that tells the compiler what kind of result to expect.

A function declaration tells the compiler, “This function exists, and here’s how it should be called.”

It does not contain the body of the function—just the signature and return type.

A function definition provides the actual implementation of a function. It includes:
- The return type
- The function name
- The parameter list
- The body (code that runs when the function is called)

A function prototype is a declaration that tells the compiler, “This function exists, and here’s how it should be called.”

It’s usually placed before main() or in a header file so the compiler knows about the function before it’s used.

Microsoft Copilot

2025年8月12日星期二

Quiz

In C++, a struct (short for "structure") is a user-defined data type that groups related variables under one name. It’s similar to a class, but by default, its members are public rather than private.

In C++, double is a primitive data type used to store floating-point numbers with double precision. That means it can represent decimal numbers with more digits and greater range than a float.

The line for (Resource& r : resources) is a range-based for loop in C++, and it means:
“For each Resource object r in the container resources, do something.”

The switch statement in C++ is a control structure used to execute different blocks of code based on the value of a variable—typically an int, char, or enum. It’s a cleaner alternative to multiple if-else statements when you're checking the same variable against many values.

for (declaration : container) {
    // loop body
}

Microsoft Copilot

Ranged for loops

traverse: cross

for (initialization; condition; update) {

    // Code to execute repeatedly

}


average += laptimes[i];

average = average + laptimes[i];


for (auto x : laptimes)

“For each element x in the container laptimes, do something with x.”
  • auto: Automatically deduces the type of x (e.g., double if laptimes is a vector)
  • x: A copy of each element in laptimes
  • :: Reads as “in” — like “for each x in laptimes


Microsoft Copilot

Testing a mainframe computer

commute: to travel regularly by bus, train, car, etc. between your place of work and your home

carpool: a group of car owners who take turns to drive everyone in the group to work, so that only one car is used at a time

cram: to learn a lot of things in a short time, in preparation for an exam

convertible: (of a car) having a roof that you can fold down or take off

savior: a person who rescues somebody/something from a dangerous or difficult situation

The French Resistance was a collection of groups that fought the Nazi occupation and the collaborationist Vichy regime in France during the Second World War.

decoy: a thing or a person that is used to trick somebody into doing what you want them to do, going where you want them to go, etc.

divert: to take somebody’s thoughts or attention away from something

jolt: to give somebody a sudden shock, especially so that they start to take action or deal with a situation

talk down to: to speak to somebody as if they were less important or intelligent than you

mainframe computer: a large, powerful computer, usually the center of a network and shared by many users

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

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

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

upperclassman: (in the US) a male student in the last two years of high school or college

dealership: a business that buys and sells products, especially cars, for a particular company; the position of being a dealer who can buy and sell something

within earshot: near enough to hear somebody/something or to be heard

self-proclaimed: giving yourself a particular title, job, etc. without the agreement or permission of other people

anarchist: a person who believes that laws and governments are not necessary

hippie: a person who rejects the way that most people live in Western society, often having long hair, wearing brightly colored clothes and taking illegal drugs. The hippie movement was most popular in the 1960s.

hangout: a place where somebody lives or likes to go often

pepperoni: a type of spicy sausage

rigor: the fact of being strict or severe

afterthought: a thing that is thought of, said or added later, and is often not carefully planned

assurance: a statement that something will certainly be true or will certainly happen, particularly when there has been doubt about it

stipulation: a clear and definite statement that something must be done, or about how it must be done

paradoxically: in a way that seems strange, impossible or unlikely because it has two opposite features or contains two opposite ideas


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年8月8日星期五

Computer room

    比爾·蓋茲喜歡電腦,電腦讓他思考。電腦對他馬虎的思維嚴酷無情。電腦要求他在邏輯上貫徹始終,在細節上小心注意。

    I loved how the computer forced me to think. It was completely unforgiving in the face of mental sloppiness. It demanded that I be logically consistent and pay attention to details.

disparate: so different from each other that they cannot be compared or cannot work together

rudimentary: dealing with only the most basic matters or ideas

ominously: in a way that suggests that something bad is going to happen in the future

elegance: the quality in a plan or an idea of being clever but simple

instantaneous: happening immediately

tic-tac-toe: a paper-and-pencil game for two players who take turns marking the spaces in a three-by-three grid, one with Xs and the other with Os.

infer: deduce

outstrip: to become larger, more important, etc. than somebody/something

sloppiness: ​the fact of showing a lack of care, thought or effort

rigorous: demanding that particular rules, processes, etc. are strictly followed

Algebra is a branch of mathematics that uses symbols, often letters, to represent numbers and their relationships in mathematical expressions and equations.

persevere: to continue trying to do or achieve something despite difficulties

coax: to persuade somebody to do something by talking to them in a kind and gentle way

asterisk: DJ[ˋæstərisk]

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

blistering: done very fast or with great energy

gaggle: ​a group of noisy people

stoke: to make people feel something more strongly

mosh pit: the place, just in front of the stage, where the audience at a concert of rock music dances and jumps up and down

outdo: to do more or better than somebody else

indeterminate: that cannot be identified easily or exactly

put-upon: treated in an unfair way by somebody because they take advantage of the fact that you are kind or willing to do things

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

exploit: to treat a person or situation as an opportunity to gain an advantage for yourself

If someone is jockeying for position, they are using whatever methods they can in order to get into a better position than their rivals.

rival: a person, company or thing that competes with another in sport, business, etc.

hand-me-down: ​no longer wanted by the original owner

A Renaissance DJ[rəˋneisəns] man is a term for someone who is knowledgeable, educated, and proficient in many different fields, excelling in a variety of areas.

ICBM: Intercontinental Ballistic Missile

muttonchops: long hair growing down each side of a man's face

goad: stimulate

bait: a person or thing that is used to attract somebody in order to catch them or make them do what you want

gadget: DJ[ˋgædʒit] a small tool or device that does something useful

cerebral: relating to the mind rather than the feelings

foursome: a group of four people taking part in a social activity or sport together

leveler: an event or a situation that makes everyone equal whatever their age, importance, etc.

RAND is a nonprofit institution that helps improve policy and decision-making through research and analysis.

kooky: strange or crazy

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

de facto: (from Latin, formal) existing as a fact although it may not be legally accepted as existing

overseer: a person or an organization that is responsible for making sure that a system is working as it should

thrilled: very excited and pleased

poke: to push something somewhere or move it in a particular direction with a small quick movement

squabble: ​a noisy argument about something that is not very important

wrath: extreme anger

tongue-in-cheek: not intended seriously; done or said as a joke

laissez-faire: the policy of leaving things to take their own course, without interfering

oversight: the fact of making a mistake because you forget to do something or you do not notice something

rebuff: rebuff something to refuse a friendly offer, request or suggestion in an unkind way

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

Some explanations are from Google AI Overview.

2025年8月5日星期二

Reference in C++

#include <iostream>

void incrementByReference(int& ref) {
    ref++;  // Directly increments the original variable
}

int main() {
    int value = 20;
    int& rValue = value;  // Declare a reference bound to 'value'
   
    std::cout << "Before: " << value << "\n";  // Prints 20
   
    incrementByReference(rValue);
   
    std::cout << "After:  " << value << "\n";  // Prints 21
   
    // References must be initialized and cannot be reseated
   
    return 0;
}

References in C++ act as true aliases for existing objects.

Once you bind a reference to an object, any operation through that reference directly

affects the original. There’s no extra indirection or separate storage - think of the

reference as a permanent nickname for the object.


Ideal for function parameters when you want to modify the caller’s variable.

value is the caller’s variable (actual parameter) in the main() function.

Microsoft and GitHub Copilot

Pointer in C++

#include <iostream>

void incrementByPointer(int* ptr) {
    if (ptr) {
        (*ptr)++;  // Dereference pointer, then increment the pointee
    }
}

Line 1. Function Signature - Return type is void, so nothing comes back to the caller. - Parameter is int* ptr, a pointer to an int.

Line 2. Null Check
Guarding against a null pointer prevents undefined behavior if someone accidentally calls
incrementByPointer(nullptr).

Line 3. Dereference & Increment
- The parentheses ensure you dereference ptr first, yielding the int it points to.
- The ++ then increments that int in place.
Note: Writing ptr++ would advance the pointer itself, not the value it points to.

int main() {
    int value = 10;
    int* pValue = &value;  // Declare a pointer and take the address of 'value'
   
    std::cout << "Before: " << value << "\n";  // Prints 10
   
    incrementByPointer(pValue);
   
    std::cout << "After:  " << value << "\n";  // Prints 11

When you see both ptr and pValue in the code, they’re actually two separate pointer variables that refer

to the same int in memory, but they live in different scopes and serve different roles.

Roles and Scope

    pValue

Declared in main().

Holds the address of value.

Its lifetime is the entire execution of main.

You use it to pass &value into functions or perform pointer arithmetic in main.

    ptr

Declared as a parameter in incrementByPointer(int* ptr).

Receives a copy of pValue (the address).

Its lifetime is the duration of the function call.

You use it inside incrementByPointer to modify the pointee.


The literal "\n" represents a single newline character in C++ strings.

When inserted into an output stream, it moves the cursor to the beginning of the next line.

    // Pointer arithmetic example
    int arr[] = {1, 2, 3};
    int* pArr = arr;  // Points to the first element
    std::cout << "Second element via pointer arithmetic: "
              << *(pArr + 1) << "\n";  // Prints 2
   
    return 0;
}

arr decays to int* pointing at the first element.

pArr + 1 advances the pointer by one int (4 bytes on most platforms).

The dereference *(pArr+ 1) yields the second element, exactly like arr[1].

Output:

Second element via pointer arithmetic: 2


Microsoft Copilot

His friend

unruly: not readily ruled, disciplined, or managed

cleft lip: a birth defect characterized by one or more clefts in the upper lip resulting from failure of the embryonic parts of the lip to unite

impediment: a problem, for example a stammer, that makes it more difficult for somebody to speak, hear, etc.

stammer: a problem that somebody has in speaking in which they repeat sounds or words or often stop, before saying things correctly

orthodontia: the treatment of irregularities in the teeth and jaws.

slackly: loosely

A Unitarian minister is a religious leader in the Unitarian or Unitarian Universalist (UU) tradition.

clique: a small group of people who spend their time together and do not allow others to join them

pursue: to do something or try to achieve something over a period of time

tumultuous: involving many difficulties and a lot of change and often violence

assassination: DJ[ə͵sæsiˋneiʃən] the murder of an important or famous person, especially for political reasons

convention: a large meeting of the members of a profession, a political party, etc.

bow out: to stop taking part in an activity, especially one in which you have been successful in the past

vying: vie: to compete strongly with somebody in order to obtain or achieve something

vehemently: ​in a way that shows very strong feelings, especially anger

devour: to read or look at something with great interest and enthusiasm

senator: a member of a senate

senate: one of the two groups of elected politicians who make laws in some countries, for example in the US, Australia, Canada and France. The Senate is smaller than the other group but higher in rank. Many state parliaments in the US also have a Senate.

decry: to strongly criticize somebody/something, especially publicly

conspiracy theory: the belief that a secret but powerful organization is responsible for an event

plot: a secret plan made by a group of people to do something wrong or illegal

idolize: to admire or love somebody very much, possibly too much

LBJ: Lyndon B. Johnson

liberal: a person who supports individual freedom and rights, democracy and free enterprise (= businesses competing against each other with little government control)

carpet: to cover something with a thick layer of something

canvass:  to ask people to support a particular person, political party, etc., either by going around an area and talking to people or by phoning them

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

stake out: ​to watch a place secretly, especially for signs of illegal activity

pudgy: ​slightly fat

bump into: (informal) to meet somebody by chance

take on: to begin to have a particular quality, appearance, etc.

machination: a secret and complicated plan

obsess: to completely fill your mind so that you cannot think of anything else, in a way that is not reasonable or normal

mitigate: to make something less harmful, serious, etc.

intrigue: to make somebody very interested and want to know more about something

disquisition: a long complicated speech or written report on a particular subject

ding: to speak with tiresome reiteration

shortcoming: ​a fault in somebody’s character, a plan, a system, etc.

outline: to give a description of the main facts or points involved in something

slog: a hard journey

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

slosh: to move around making a lot of noise or coming out over the edge of something

inundate: overflow

fled: flee: to leave a person or place very quickly, especially because you are afraid of possible danger

aside from: except for

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

envision: to imagine what a situation will be like in the future, especially a situation you intend to work towards

Douglas MacArthur (26 January 1880 - 5 April 1964) was an American general who served as a top commander during World War II and the Korean War.

dissect something: to study something closely and/or discuss it in great detail

decipher: to succeed in finding the meaning of something that is difficult to read or understand

"Lucy in the Sky with Diamonds" is a song by the English rock band the Beatles, featured on their 1967 album Sgt. Pepper's Lonely Hearts Club Band.

marvel at: to show or experience great surprise or admiration

flaw: a mistake in something that means that it is not correct or does not work correctly

appointee: a person who has been chosen for a job or position of responsibility

clout: DJ[klaut] power and influence

prodigious: ​very large or powerful and causing surprise; impressive

A clapboard is a type of siding, traditionally made of long, thin, overlapping wooden boards, used to cover the exterior of buildings.

A cog railway is a type of railway that uses a toothed rack rail, usually between the running rails, to climb steep slopes.

hunch over: to bend the top part of your body forward and raise your shoulders and back

rotary: moving in a circle around a central fixed point

A teletype machine, also known as a teletypewriter or teleprinter, is an electromechanical device that transmits and receives typed messages over communication channels.

In computing, time-sharing refers to a method of sharing a computer's resources, typically the CPU, among multiple users or processes concurrently.

concurrently: at the same time

parcel out: to divide something into parts or between several people

caliber: the quality of something, especially a person’s ability

An ordained minister is a member of the clergy who has been formally recognized and authorized by a religious institution to perform religious rites and ceremonies.

freewheeling: not concerned about rules or the possible results of what you do

aeronautical: connected with the science or practice of building and flying aircraft

avid: very enthusiastic about something (often a hobby)

sabbatical: a period of time when somebody, especially a teacher at a university, is allowed to stop their normal work in order to study or travel

sacred: very important and treated with great respect; that must not be changed or challenged

infamous: notorious

trek: a long, hard walk lasting several days or weeks, especially in the mountains

intrepid: very brave; not afraid of danger or difficulties

lease: a legal agreement that allows you to use a building, a piece of equipment or some land for a period of time, usually in return for rent

rummage sale: a sale of old or used clothes, etc. to make money for a church, school or other organization

cutting-edge: at the newest, most advanced stage in the development of something

amusing: funny and giving pleasure

hunch: a feeling that something is true even though you do not have any evidence to prove it

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

Some explanations are from Google AI Overview.

2025年7月30日星期三

New School

station wagon: an automobile that has a passenger compartment which extends to the back of the vehicle, that has no trunk, that has one or more rear seats which can be folded down to make space for light cargo, and that has a tailgate or liftgate

tailgate: the door that opens upwards at the back of a car (called a hatchback) that has three or five doors

liftgate: a rear panel that opens upward

A college feeder is a school, typically a high school, that sends a disproportionately high number of students to a particular college or university, or a specific type of higher education institution.

disproportionately: in a way that is too large or too small when compared with something else

abolish: abolish something to officially end a law, a system or an institution

While A Separate Peace has not been banned, it has been challenged six times between 1980 and 1996 in six different counties. Most of the complaints about the book cite offensive language; several complaints also include homosexual themes and negative attitudes expressed by characters.

county: one of a number of areas that some countries are divided into, each with its own local government

clip: to cut something with scissors or shears, in order to make it shorter or neater; to remove something from somewhere by cutting it off

upperclassman: ​(in the US) a male student in the last two years of high school or college

fame: the state of being known and talked about by many people

championship: a competition to find the best player or team in a particular sport

forestry: the science or practice of planting and taking care of trees and forests

the ropes [plural]: the fence made of rope that is around the edge of the area where a boxing or wrestling match takes place

A glee club is a group of people who sing together, often in a school or university setting.

shtick: a style of humor that is typical of a particular performer

goof-off: ​a person who avoids work or responsibility

fellowship: (formal) a feeling of friendship between people who do things together or share an interest

depiction: the act of showing somebody/something in a particular way in words or pictures, especially in a work of art

loner: a person who is often alone or who prefers to be alone, rather than with other people

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

obnoxious: extremely unpleasant, especially in a way that offends people

Avid generalist refers to someone who is highly skilled and knowledgeable across a broad range of subjects or fields, rather than specializing in a single area.

crew cut: a hairstyle in which the hair is cut very short

pump-fake: in football and basketball, an action in which a player deceives their opponent by pretending to throw the ball in a particular direction, or by pretending to move in a particular direction

clown: a person that you think is bad because they act in a stupid way

sting: to make somebody feel angry or upset

redeem somebody/something: to make somebody/something seem less bad

crib: to dishonestly copy work from another student or from a book

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

opus: an important piece of literature, etc., especially one that is on a large scale

exhortation (to do something): an act of trying very hard to persuade somebody to do something

oblige: DJ[əˋblaidʒ] to help somebody by doing what they ask or what you know they want

extensive: including or dealing with a wide range of information


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

Some explanations are from Google AI Overview.

2025年7月29日星期二

20 mg Simvastatin q.d.

Over-the-counter (OTC) medicines are medications that can be purchased without a prescription from a healthcare professional. They are used to treat a variety of common ailments (minor illness) and their symptoms. While readily available, it's crucial to use them safely and responsibly.

In Hong Kong, most cholesterol lowering drugs can only be obtained from pharmacy with a prescription. They should be used under close supervision by healthcare professionals.

for loops

In C++, vector<int> is a dynamic array from the Standard Template Library (STL) that stores integers. Unlike regular arrays, vectors can grow or shrink in size during runtime.

for (initialization; condition; update) {
    // Code to execute in each iteration
}

average += laptimes[i];
is equivalent to
average = average + laptimes[i];

average/= laptimes.size();
is equivalent to
average = average / laptimes.size();

Microsoft Copilot

Contemporary Club

run-up (to something) a period of time leading up to an important event; the preparation for this

orchestrate something: to organize a complicated plan or event very carefully or secretly

dessert: DJ[diˋzə:t]

masterful: showing great skill or understanding

wrestle: to struggle physically to move or manage something

horse around: to play in a way that is noisy and not very careful so that you could hurt somebody or damage something

get off the hook: to manage to get out of the awkward situation you are in without being punished or blamed

awkward: difficult to deal with

weave: to put facts, events, details, etc. together to make a story or a closely connected whole

a jolt of electricity: a sudden, brief, and often painful sensation caused by the flow of electrical current through the body

devise something: to invent something new or a new way of doing something

edge up: to approach or move toward a target little by little

patent: an official right to be the only person to make, use or sell a product or an invention; a document that proves this

downtown: ​in, towards or typical of the center of a city, especially its main business area

fictitious: invented by somebody rather than true

contemporary: belonging to the present time

Gondoliers are more than just boat men. They are the keepers of a tradition that has been passed down from generation to generation.

brim: the top edge of a cup, bowl, glass, etc.

straw: stems of wheat or other grain plants that have been cut and dried. Straw is used for making mats, hats, etc., for packing things to protect them, and as food for animals or for them to sleep on.

think tank: a group of experts who provide advice and ideas on political, social or economic issues

spin out: ​to make something last as long as possible

leash: something that restrains : the state of being restrained

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

waver: to be or become weak or unsteady

replica: ​a very good or exact copy of something

Fiddler on the Roof is a musical with music by Jerry Bock, lyrics by Sheldon Harnick, and book by Joseph Stein, set in the Pale of Settlement of Imperial Russia in or around 1905.

in the fall: in autumn

tuition: the money that you pay to be taught, especially in a college or university

tank:  tank (something) (North American English, sport) to lose a game, especially deliberately

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

prevail: (of ideas, opinions, etc.) to be accepted, especially after a struggle or an argument


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

Some explanations are from Google Search Engine.

2025年7月25日星期五

Observing adults

confer: to discuss something with somebody, in order to exchange opinions or get advice

gist: the main or general meaning of a piece of writing, a speech or a conversation

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

stunned: very surprised or shocked

dash: ruin

stake out: to clearly mark the limits of something that you claim is yours

intuitively: by using your feelings rather than by considering the facts

give in: to admit that you have been defeated by somebody/something

ease up: to become less strong, unpleasant, etc.

come out: to be produced or published

choke up: to find it difficult to speak, because of the strong emotion that you are feeling

strip something out: to ignore particular numbers or facts in a situation in order to understand what is really important

brink: if you are on the brink of something, you are almost in a very new, dangerous or exciting situation

intrigued: DJ[inˋtri:gd] very interested in something/somebody and wanting to know more about it/them

animatedly: in a way that shows interest and energy

consequential: happening as a result or an effect of something

Dictaphone: a small machine used to record people speaking, so that their words can be played back later and written down

Xerox: a process for producing copies of letters, documents, etc. using a special machine

decipher: to succeed in finding the meaning of something that is difficult to read or understand

scribble: to write something quickly and carelessly, especially because you do not have much time

peek: to look at something quickly and secretly because you should not be looking at it

meticulous: paying careful attention to every detail

deposition: a formal statement, taken from somebody and used in court

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

coolheaded: calm; not showing excitement or nerves

unwavering: not changing or becoming weaker in any way

metrics [plural]: a set of numbers or statistics used for measuring something, especially results that show how well a business, school, computer program, etc. is doing

accomplishment: an impressive thing that is done or achieved after a lot of work

In the card game bridge, a bridge partner refers to the other player on your team. 


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

Some explanations are from Google AI Overview

2025年7月23日星期三

Selecting the right while loop

while (condition){
    // Code to execute
}

do{
    // Code to execute
}while (condition);

The do...while loop is executed at least once.

negate: to stop something from having any effect

The exclamation mark ! is the logical NOT operator. It inverts a boolean value.

getline is a handy function in C++ for reading a whole line of text, especially when you're dealing with strings that might include spaces.

getline(cin, userInput); // reads full line including spaces

std::getline(std::cin, playerName);

using std::getline from the <string> header to read a full line of input into playerName

\n is a newline character used in C++.

do{
    // Code to execute
}while (choice != 3);

repeats until they select option 3

Microsoft Copilot

2025年7月22日星期二

While loops

In C++, the auto keyword is used for type inference, which means the compiler automatically deduces the variable's type from its initializer. It’s incredibly handy when dealing with complex types or simply to make your code cleaner.

Pointer = next(Pointer, 1);

Pointer = std::next(Pointer, 1);

++Pointer;

Think of an iterator as a pointer-like object that lets you access and traverse elements of a container. It abstracts away the underlying structure, making your code flexible and reusable.

The keyword do in C++ is most commonly seen as part of the do...while loop—a control structure that executes code at least once before checking a condition. It's great when you want to ensure a block of code runs before validating any exit condition.

do {
    // Code to execute
} while (condition);

++count: increments count before its value is used
count++: increments count after its value is used

In C++, .size() is a method used to retrieve the number of elements in a container from the Standard Template Library (STL). It’s simple but powerful when you need to know the container’s current size.

std::vector<int> scores = {1, 2, 3, 4, 5};

I declared and initialized a std::vector<int> named scores with the values {1, 2, 3, 4, 5}

std::cout << "First score: " << scores[0] << std::endl;

scores.push_back(6);

std::cout << "Total scores: " << scores.size() << std::endl;

Microsoft Copilot

廣袤

「廣袤」的意思是土地的面積,東西向稱為「廣」,南北向稱為「袤」。 也可以引申為開闊、寬廣的意思。 例如,可以說「這片草原廣袤無垠」,表示草原非常廣闊,望不到邊際。 「廣袤」也可以用來形容其他空間的遼闊,例如「天空廣袤」。粵音同「貿」。

Google AI

Counseling

Without being prescriptive, Dr. Cressey helped me see that my parents loved me; I wouldn't be under their roof forever; they were actually my allies in terms of what really counted; it was absurd to think that they had done anything wrong.

在不採取說教方式的情況下,

Dr. Cressey幫助作者看清父母是愛他的;

他終究不會永遠住在父母的屋簷下;

在真正重要的事情上,他們其實是作者的盟友;

要認為他們做錯了什麼簡直荒謬。

進一步的闡釋︰

雖然作者暫時受制於父母的安排,但這並不會成為終身桎梏,而是一段生命必經的過程。

由抗拒到理解,作者認清真正值得追求的目標時,父母成了最堅實的後盾,而非阻力。

sexist: treating other people, especially women, unfairly because of their sex or making offensive remarks about them

An airline hostess, also known as a flight attendant or cabin crew, is a member of the aircrew responsible for passenger safety and comfort during flights.

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

doggedly: in a way that shows that you are determined and do not give up easily

unnerved: to make somebody feel nervous or frightened or lose confidence

In baseball, a wild pitch occurs when a pitcher throws the ball to the batter in a way that the catcher cannot control with ordinary effort, and as a result, a base runner advances to the next base. 

cohort: a group of people who share a common feature or aspect of behavior

A growth spurt is a period of rapid physical development, primarily characterized by an increase in height and weight.

galumph: to move in a heavy, careless or noisy way

Coming of age refers to the transition from childhood to adulthood.

thrill: a strong feeling of excitement or pleasure; an experience that gives you this feeling

goof around: to spend your time doing silly or stupid things

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

The brass section of an orchestra or band consists of the musicians who play brass instruments.

trombone: a large brass musical instrument that you blow into, with a sliding tube used to change the note

lug: to carry or drag something heavy with a lot of effort

circular: a letter, notice or advertisement that is sent to a large number of people at the same time

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

toss: to throw something lightly or carelessly

porch: a small area at the entrance to a building, such as a house or a church, that is covered by a roof and often has walls

dreaded: causing fear

murmur: to say something in a soft quiet voice that is difficult to hear or understand

spank: to hit somebody, especially a child, several times on their bottom as a punishment

disciplinarian: ​a person who believes in using rules and punishments for controlling people

intimidating: frightening in a way that makes a person feel less confident

Towering stature refers to someone or something having a very tall or impressive height. It can also be used metaphorically to describe someone or something that is outstanding in terms of importance, influence, or power.

intrinsically: ​in a way that belongs to or is part of the real nature of somebody/something

punitive: intended as punishment

collaborative: involving, or done by, several people or groups of people working together

suck up: to try to please somebody in authority by praising them too much, helping them, etc., in order to gain some advantage for yourself

smart aleck: a person who thinks they are very clever and likes to show people this in an annoying way

snap: to speak or say something in an impatient, usually angry, voice

turmoil: a state of great worry in which everything is confused and nothing is certain

Plaster walls are a construction detail where a layer of plaster is applied to a surface, typically walls and ceilings, to create a smooth, finished appearance. Plaster can be used for both decorative and protective purposes, and is often applied over brick, concrete, or other materials.

hard-pressed: having a lot of problems, especially too much work, and too little time or money

disarming: making people feel less angry or likely to suspect somebody than they were before

lead up to: to be an introduction to or the cause of something

sparingly: ​in a way that is careful to use or give only a little of something

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

avid: very enthusiastic about something (often a hobby)

Carl Jung was a Swiss psychologist and psychiatrist who founded analytic psychology.

intriguing: very interesting because of being unusual or not having an obvious answer

prescriptive: telling people what should be done

absurd: extremely silly; not logical and sensible

dispense with: ​to stop using somebody/something because you no longer need them or it

belittle: ​to stop using somebody/something because you no longer need them or it


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

Some explanations are came from Google AI and Microsoft Copilot.

2025年7月20日星期日

Switch statements

In C++, a switch statement is used to execute one out of multiple code blocks based on the value of a variable. It’s especially handy when dealing with multiple if-else conditions that all check the same variable.

handy: easy to use or to do

The expression must evaluate to an integral or enumeration type (int, char, enum, etc.).

Each case compares the expression against a constant.

Use break to stop execution after a matching case—if omitted, execution "falls through" to the next case.

Default is optional and acts as a fallback when no case matches.

std::flush is a stream manipulator in C++ used to force the output buffer to flush immediately—meaning all characters that have been sent to the stream are written out, even if the buffer isn’t full

Microsoft Copilot

Lucky Kid

set into: to insert or embed something into a surface or object, so that it is securely held in place

back deck: an outdoor platform, usually made of wood or composite materials, that is attached to the back of a house

strew: to cover a surface with things

confiscate: to officially take something away from somebody, especially as a punishment

when you rev an engine or it revs, it runs quickly

rustle: if something dry and light rustles or you rustle it, it makes a sound like paper, leaves, etc. moving or rubbing together

thrilled: very excited and pleased

stiffness: the fact of being hard and difficult to bend or move

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

contrarian: a person who opposes or rejects popular opinion, especially in financial markets

troll: to search for or try to get something

brochure: a small magazine or online document containing pictures and information about something or advertising something

The Lenni Lenape, also known as the Delaware Indians, are an Indigenous people of the Northeastern Woodlands.

indigenous: (of people and their culture) coming from a particular place and having lived there for a long time before other people came there; relating to, belonging to or developed by these people

chronology: ​the order in which a series of events happened; a list of these events in order

quaint: attractive in an unusual or old-fashioned way

fictitious: invented by somebody rather than true

granite: ​a type of hard grey stone, often used in building

muster: collect or assemble

fabricate: to make or produce goods, equipment, etc. from various different materials

jester: a man employed in the past at the court of a king or queen to entertain people by telling jokes and funny stories

tome: ​a large, heavy book, especially one dealing with a serious topic

take root: (of an idea) to become accepted widely

accrue: to increase over a period of time

empowerment: the act of giving somebody more control over their own life or the situation they are in


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年7月17日星期四

If-else

The ternary conditional operator is a compact way to write conditional expressions in many programming languages. It’s called “ternary” because it takes three operands: a condition, a result if true, and a result if false.

In C++, the return statement is used to exit a function and optionally send a value back to the caller. It’s a key part of how functions communicate results.

++x Increment first, then use the value

x++ Use the value first, then increment

parentheses: DJ[pəˋrenθisi:z]

versatile: DJ[ˋvə:sətail] able to do many different things

Microsoft Copilot

2025年7月15日星期二

If statements in C++

No "then" keyword

In C++, the percent symbol % is used as the modulus operator. It calculates the remainder after dividing one integer by another.

In C++, == is the equality operator. It checks whether two values are equal and returns true if they are, and false otherwise.

In C++, bool is a built-in type used to represent Boolean values—essentially, values that are either true or false.

1: true

0: false

In C++, != is the inequality operator. It checks whether two values are not equal. If they are different, it returns true; if they’re the same, it returns false.

In C++, && is the logical AND operator, used to combine two Boolean expressions. It returns true only if both expressions are true—otherwise, it returns false.

affirmative: (also positive) (of a statement) expressing something that is true, did happen, etc.; not containing words such as ‘no’, ‘not’, ‘never’, etc.

subtle: not very obvious or easy to notice

Microsoft Copilot

Retarded?!

    If these supposed experts do not know what to do with me, why should I care about their opinions?

crackle: to make short sharp sounds like something that is burning in a fire

intercom: a system of communication by phone or radio inside an office, plane, etc.; the device you press or switch on to start using this system

roust: to drive (as from bed) roughly or unceremoniously

unceremoniously: in a rough or rude way, without caring about a person’s feelings

blast out:  to make a loud unpleasant noise, especially music

impeccably: in a way that has no mistakes or faults

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

feminist: ​DJ[ˋfeminist] having or based on the belief that women should have the same rights and opportunities as men

pantsuit: ​a woman’s suit of jacket and pants

assert something to: make other people recognize your right or authority to do something, by behaving in a determined and confident way

mystique: the quality of being mysterious or secret that makes somebody/something seem interesting or attractive

rung: ​one of the bars that forms a step in a ladder

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

soccer: DJ[ˋsɔkə]

memorabilia: things that people collect because they once belonged to a famous person, or because they are connected with a particular interesting place, event or activity

maxim: a well-known phrase that expresses something that is usually true or that people think is a rule for sensible behavior

endeavor: an attempt to do something, especially something new or difficult

reveille: a tune that is played to wake soldiers in the morning; the time when it is played

makeshift: used temporarily for a particular purpose because the real thing is not available

overpass: ​a bridge that carries one road over another one

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

aggression: a violent attack or threats by one person against another person or by one country against another country

scrawny: ​(of people or animals) very thin in a way that is not attractive

squeaky: making a short, high sound

brawler: ​a person who takes part in a noisy and violent fight, usually in a public place

​engender something: to make a feeling or situation exist

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

jock: a man or boy who plays or enjoys sport a lot, especially one who does not have many other interests

studious: spending a lot of time studying or reading

diligent: ​showing care and effort in your work or duties

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

differentiator: one that differentiates

niche: a comfortable or suitable role, job, way of life, etc.

wallow (in something) (of large animals or people): to lie and roll about in water or mud, to keep cool or for pleasure

when people ham it up, they deliberately exaggerate their emotions or movements

exaggerate: to make something seem larger, better, worse or more important than it really is

gloat: to show that you are happy about your own success or somebody else’s failure, in an unpleasant way

feat: ​an action or a piece of work that needs skill, strength or courage

punctuation: the marks used in writing that divide sentences and phrases; the system of using these marks

verdict: a decision that you make or an opinion that you give about something, after you have tested it or considered it carefully

kindred: very similar; related

foghorn: a device that makes a loud noise to warn ships of danger in fog

contrarian: a person who opposes or rejects popular opinion, especially in financial markets

streak: a part of a person’s character, especially an unpleasant part

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

jokester: joker

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

outwardly: on the surface; in appearance

clash over: an argument between two people or groups of people who have different beliefs and ideas

epic: taking place over a long period of time and involving a lot of difficulties

physicality: the quality of being physical rather than emotional or spiritual

tow-headed: having very light blonde or untidy hair

linebacker: (in American football) a defensive player who tries to tackle members of the other team

touchdown: (in American football) an act of scoring points by crossing the other team’s goal line while carrying the ball, or receiving the ball when you are over the other team’s goal line

complimentary: expressing approval, praise, etc.

thrilled: DJ[θrild] very excited and pleased

domino theory: a theory that if one nation becomes Communist-controlled the neighboring nations will also become Communist-controlled

hands down: (informal) easily and without any doubt


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

2025年7月13日星期日

Registered Nurse

    目標實現了,便是光榮;目標實現不了,人生也會因這一路風雨跋涉變得豐富而充實;在我看來,這就是不虛此生。

節錄自汪國真《我喜歡出發》

Auto Focus

AF-S (AF single, sometimes called single area AF) mode, is good for photographing subjects that do not move, such as flowers or portraits etc.

www.slrphotographyguide.com

Baby

hangman: a game in which one player chooses a word and the other players try to guess it, letter by letter. Each time they guess wrongly, the first person draws one part of a person being hanged. The other players have to guess the word before the drawing is complete

gallows: a structure on which people, for example criminals, are killed by hanging

mitigate something: to make something less harmful, serious, etc.

rambunctious: full of energy in a cheerful and noisy way

floor somebody: to surprise or confuse somebody so that they are not sure what to say or do

disruptive: causing problems, noise, etc. so that something cannot continue normally


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年7月11日星期五

On the Stage by Yoasobi

So, I'm standing on the top of the stage of my dreams

And now the signal echoes loud in my ears

Time after time, been imagining this moment

Outdoing all versions of me, I'll prevail

Taking a deep breath, inhale and exhale

And in silence I raise my gaze, it unveils

Everything I've done up to this point of time

I realize wasn't in vain, but led to now

No doubt, the future that I have seen in my dreams

Has started now, unfolding where I stand

outdo somebody/something: to do more or better than somebody else

prevail: [intransitive] to exist or be very common at a particular time or in a particular place

unveil something: to remove a cover or curtain from a painting, statue, etc. so that it can be seen in public for the first time

in vain: without success

Online Dictionary Used: www.oxfordlearnersdictionaries.com

2025年7月10日星期四

Tutankhamun

故宮館十一月古埃及展 圖坦卡門巨像助陣

    【明報專訊】香港故宮文化博物館十一月二十日推出逾九個半月的特別展覽「古埃及文明大展︰埃及博物館珍藏」,將展示二百五十件埃及文物,包括法老與諸神雕像、大型成套木乃伊棺、動物木乃伊等,皆首次在港亮相,當中不少亦是首次在埃及境外巡展。故宮館長吳志華昨表示,門票銷售安排八月公布,將是「所有人皆負擔得起」的票價,盼吸引六十萬至七十萬入場人次。

共七間博物館二百五十件藏品 遠溯七千三百年

    香港故宮館與埃及最高文物委員會昨簽訂合作協議,在港合辦「古埃及文明大展︰埃及博物館珍藏」。特別展覽分成「法老的國度」、「圖坦卡門的傳奇」、「薩卡拉的秘密」及「古埃及與世界」共四個單元,囊括埃及七間重要博物館共二百五十件藏品,最久遠可追溯至七千三百年前,最年輕的距今亦已二千年。

    「圖坦卡門的傳奇」將介紹少年法老圖坦卡門的一生及其陵墓的考古發現,展出包括高逾二點八米的巨型石雕「圖坦卡門巨像」。圖坦卡門繼位時僅九歲,任內推翻「一神教」宗教改革,帶領埃及回歸傳統多神信仰,惟十八歲就逝世,其官方紀錄亦遭後繼者赫倫布抹去,至一九二二年始由考古學家挖掘出圖坦卡門的陵墓。

    另一單元「薩卡拉的秘密」則聚焦薩卡拉遺址的考古成果,展出彩繪人形棺、動物木乃伊及神像等,重點展品包括「芭絲特持叉鈴像」及「貓木乃伊」。芭絲特女神常以貓頭人身或直接以貓的形象示人,原為戰爭女神,後期與母性、家庭與保護有更大聯繫,兼具音樂、舞蹈和美等職能。古埃及人會大量飼養貓並製作木乃伊獻予芭絲特女神祈求保佑。

    其餘兩個單元為「法老的國度」及「古埃及與世界」。前者會聚焦法老時代的古埃及文明發展,後者則會探討古埃及和世界其他文明的交流與對話。

港最大埃及展 盼九個月吸七十萬人

    特別展覽展期至明年八月底結束。港故宮表示,今次展覽乃本港史上規模最大且展期最長的古埃及文物展,亦是埃及最高文物委員會第二次與亞洲博物館合辦展覽,盼紀念中國與埃及兩大文明古國建交七十周年。吳志華相信今次展覽非常受歡迎,目標吸引六十萬至七十萬人次。

二零二五年六月二十七日

2025年7月8日星期二

Arrays, Pointers and Strings

*distances.begin()

Adding the asterisk * dereferences that iterator, giving you access to the actual value stored at that position.

When you declare something as public in a class, it means it’s accessible from outside the class.

class MyClass {
public:
    void sayHello() {
        std::cout << "Hello from public method!" << std::endl;
    }
};

int main() {
    MyClass obj;
    obj.sayHello();  // Totally fine—sayHello is public
    return 0;
}

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

In C++, a C string (also called a C-style string) is a sequence of characters stored in a character array and terminated by a null character ('\0'). 

In C++, arrays and pointers are closely related --- but not identical. Their relationship is one of the most fundamental (and sometimes confusing) aspects of the language.

Array name as a pointer: In most contexts, the name of an array decays into a pointer to its first element.

int arr[5] = {10, 20, 30, 40, 50};
int* ptr = arr;  // Equivalent to: int* ptr = &arr[0];

Microsoft Copilot

School Life

ironclad: so strong that it cannot be challenged or changed

undermine: to make something, especially somebody’s confidence or authority, gradually weaker or less effective

arbitrary: DJ[ˋɑ:bi͵trəri] not seeming to be based on a reason, system or plan and sometimes seeming unfair

bear the brunt of something: to receive the main force of something unpleasant

recalcitrance: the fact of being unwilling to obey rules or follow instructions; the fact of being difficult to control

stalemate: a disagreement or a situation in a competition in which neither side is able to win or make any progress

transgression: an act that goes beyond the limits of what is morally or legally acceptable

snide: ​criticizing somebody/something in an unkind and indirect way

muster: to find as much support, courage, etc. as you can

bratty: (of a person, especially a child) badly behaved

wiseass: smart aleck

smart aleck: an obnoxiously conceited and self-assertive person with pretensions to smartness or cleverness

obnoxiously: in an extremely unpleasant way, especially in a way that offends people

conceited: being too proud of yourself and what you do

self-assertive: very confident and not afraid to express your opinions

pretension: ​the act of trying to appear more important, intelligent, etc. than you are in order to impress other people

pull back: to move back from a place

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

deliberate: done on purpose rather than by accident

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

jibe: to say something that is intended to make somebody look silly or feel embarrassed

The Wind in the Willows: novel by Kenneth Grahame

roam: (of the eyes or hands) to move slowly over every part of somebody/something

caveman: a person who lived in a cave thousands of years ago

dictate: to control or influence how something happens

husbandry: farming, especially when done carefully and well

sleuthing: the act of investigating a crime or mysterious event


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

2025年7月6日星期日

The string class

The object-oriented approach (often shortened to OOP) is a way of designing and writing software by organizing code around objects rather than just functions and logic. It’s one of the most popular programming paradigms and is used in many modern languages like Java, Python, C++, and C#.

In C++: <string>
This header provides the std::string class, a more powerful and safer alternative to C-style strings.
It supports:
- Dynamic memory management
- Operator overloading (e.g., +, ==)

Dynamic memory management is the process of allocating and freeing memory at runtime, rather than at compile time. It’s essential when you don’t know in advance how much memory your program will need --- like when handling user input, working with large datasets, or building flexible data structures like linked lists or trees.

In C++, strncpy() is a legacy function inherited from the C standard library, defined in the <cstring> header. It’s used to copy a fixed number of characters from one C-style string to another. While it works in C++, it's generally recommended to use std::string for safer and more expressive string handling.

In C++, strncat() is a legacy function from the C standard library used to append a limited number of characters from one C-style string to another. It’s declared in the <cstring> header and works directly with character arrays.

semantics: the study of the meanings of words and phrases

concatenation: a series of things or events that are linked together

exhaustive: including everything possible; very careful or complete

Microsoft Copilot
www.oxfordlearnersdictionaries.com

2025年7月3日星期四

His teacher

"Fall of a year" refers to the season of autumn, especially in North America.

qualm: a feeling of doubt or worry about whether what you are doing is right

unbeknownst: without the person mentioned knowing

penmanship: ​the art of writing by hand; skill in doing this

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

showboating: behavior that is intended to show people how clever, skillful, etc. you are

flute: a musical instrument of the woodwind group, like a thin pipe in shape. The player holds it to the side of his or her face and blows across a hole at one end.

memento: a thing that you keep or give to somebody to remind you or them of a person or place

slaughterhouse: a building where animals are killed for food

seep: (especially of liquids) to flow slowly and in small quantities through something or into something

unveil: to remove a cover or curtain from a painting, statue, etc. so that it can be seen in public for the first time

awe: feelings of respect and slight fear; feelings of being very impressed by something/somebody

appalled: feeling or showing horror at something unpleasant or wrong

crackle: to make short sharp sounds like something that is burning in a fire

scribble: to write something quickly and carelessly, especially because you do not have much time


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

2025年7月2日星期三

Tile

encaustic: a paint made from pigment mixed with melted beeswax and resin and after application fixed by heat

Stoke-on-Trent: city in England

www.merriam-webster.com/dictionary

2025年7月1日星期二

C strings

consecutive: following one after another in a continuous series

The null character --- written as '\0' in C and C++ --- is a special character used to mark the end of a string in many programming languages, especially those influenced by C.

<cstring> Header in C++

This is part of the C++ Standard Library, inherited from C’s <string.h>. It provides functions for manipulating C-style strings (null-terminated character arrays).

The String class is a fundamental part of many programming languages, used to represent and manipulate sequences of characters.

std::string greeting = "Hello";
greeting += " World";
std::cout << greeting;  // Output: Hello World

size_t is a special unsigned integer type used in C and C++ to represent the size of objects in memory or array indices.

An unsigned integer is a whole number data type that can only represent non-negative values—that is, zero and positive numbers.

A character array is a data structure used to store a sequence of characters --- essentially, it's how many programming languages represent strings under the hood.

ASCII stands for American Standard Code for Information Interchange. It’s a character encoding standard that assigns numeric values to letters, digits, punctuation marks, and control characters so computers can store and exchange text reliably.

In C++, strncpy() is a function from the C standard library (inherited via <cstring>) used to copy a fixed number of characters from one C-style string to another. It's a bit of a double-edged sword --- powerful but easy to misuse if you're not careful.

The sizeof operator in C and C++ is used to determine the size, in bytes, of a data type or object at compile time.

strncpy(name, src, sizeof(name) - 1);
name[5] = '\0';  // Manually null-terminate

Here, the -1 is used because:
You reserve the last slot for the null terminator.
You copy at most n - 1 characters to avoid overflow.
Then manually add '\0' at the end.

concatenate: to link together in a series or chain

The strcat() function in C is used to concatenate two C-style strings—that is, it appends one string to the end of another.

The strncat() function in C is used to safely concatenate a limited number of characters from one C-style string to another.

In C++, strlen() is a function from the C standard library (accessible via <cstring>) that returns the length of a null-terminated C-style string, excluding the null character '\0'.

Microsoft Copilot
www.oxfordlearnersdictionaries.com
www.merriam-webster.com

Top seller

dog-eared: (of a book) used so much that the corners of many of the pages are turned down

distillation: (formal) the process or result of getting the essential meaning, ideas or information from something

advancement: progress in a job, social class, etc.

boot camp: a training camp for new members of the armed forces, where they have to work hard

filbert: a type of hazel tree that produces oval nuts

pecan: the nut of the American pecan tree with a smooth pink-brown shell

daunting: making somebody feel nervous and less confident about doing something; likely to make somebody feel this way

tally: a record of the number or amount of something, especially one that you can keep adding to

parameter: ​something that decides or limits the way in which something can be done

pistol: a small gun that you can hold and fire with one hand

If you say that a person, a team, an organization, etc. has bragging rights, you mean that they have achieved a good result or are better or more successful than their competitors or opponents at that time.

steep: sudden and very big

pitch: to set something at a particular level

hash mark: service stripe

service stripe: a stripe worn on an enlisted person's left sleeve to indicate three years of service in the army or four years in the navy

perennial: ​continuing for a very long time; happening again and again


Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com

2025年6月29日星期日

Reference & in C++

In C++, a reference is essentially an alias for another variable. Once a reference is initialized to a variable, it becomes just another name for that variable—any operation on the reference is actually performed on the original variable.

- Declared using the & symbol

int a = 10;
int& ref = a;  // ref is a reference to a

- Must be initialized when declared.
- Cannot be changed to refer to another variable after initialization.
- Useful for function arguments and return values to avoid copying large data.

Reference:
int& ref = var;
cannot be null
cannot be reassigned
do not need dereferencing

Pointer:
int* ptr = &var;
can be null
can point to difference variables
need dereferencing

In programming, an alias is a second name for the same memory location. It means two or more variables refer to the same underlying data—so changing one affects the other.

Modifying a reference does change the original variable, because they both refer to the same memory location.

In programming, nullability refers to whether a variable is allowed to hold a null value --- meaning it can represent the absence of a value.

syntax: (computing) the rules that state how words and phrases must be used in a computer language

In C++, a reference is essentially an alias for another variable. That means:
- It doesn't exist as a separate object in memory.
- When you take the address of a reference, you're actually getting the address of the original variable it refers to.

C++ does not allow arrays of references.

References are not objects: They don’t occupy their own memory --- they’re just aliases for existing variables.

Arrays require elements to be assignable: But references must be initialized when declared and cannot be reseated.

References must be initialized at declaration.

A reference is not a standalone object; it must alias an existing variable.
Because of this, the compiler needs to know what it's referring to immediately --- there is no such thing as a "null" or "unbound" reference.

In C++, pointer initialization is optional, but that comes with a big caveat.

caveat: a warning that particular things need to be considered before something can be done

In C++, references provide one level of indirection.

indirection: indirect action or procedure

In C++, multiple levels of indirection with pointers means having pointers that point to other pointers --- and this can go as deep as your brain (or compiler) can handle!

When you use a reference:
- You're not accessing the object directly.
- Instead, you're accessing it through an alias --- a single level removed from the actual object.

In C++, you can absolutely declare a pointer with the void type, and it's known as a void pointer or generic pointer.

A void* is a special type of pointer that can point to any data type, but it doesn't know what type it's pointing to.

References in C++ are like secret passageways --- they let you access and manipulate data efficiently without the overhead of copying.

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

Microsoft Copilot
www.oxfordlearnersdictionaries.com