搜尋此網誌

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