Understanding C++ Arrays and Pointers: Essential Concepts and Examples

Arrays 1.1 One-Dimensional Arrays 1.1.1 Declaration Syntax A one-dimensional array can be declared in three ways: type name[size]; type name[size] = {val1, val2, ...}; type name[] = {val1, val2, ...}; Key characteristics: Elements occupy contiguous memory cells. All elements share the same data type. Indexing starts from 0. 10 20 30 4 ...

Posted on Sat, 05 Sep 2026 16:13:45 +0000 by jkatcherny

Understanding Pointer to Constant vs Constant Pointer vs Constant Pointer to Constant in C++

In C++, there are three distinct concepts involving const and pointers that are often confused: pointer to constant (常量指针), constant pointer (指针常量), and constant pointer to constant (const修饰的指针常量). Understanding the differences between these is essential for writing safe and correct C++ code. Key Differences Pointer to Constant ( ...

Posted on Fri, 14 Aug 2026 16:27:32 +0000 by daarius

Emulating let and const Using ES5 JavaScript Features

Early ES5 emulations of const often have critical flaws: attaching constants to the global window object makes function-declared constants accessible outside their enclosing scope, violating lexical scoping rules. Additionally, these implementations may fail to enforce immutability or prevent deletion. Below are accurate emulations of let and c ...

Posted on Mon, 06 Jul 2026 17:50:24 +0000 by Basdub

Understanding `const` in C++: Member Variables and Member Functions

In C++, the const keyword plays a crucial role in enforcing immutability, ensuring that certain data or operations cannot be modified after initialization or within specific contexts. This section explores its application to member variables and member functions. const Member Variables When a member variable is declared as const, it signifie ...

Posted on Mon, 22 Jun 2026 16:04:15 +0000 by ngreenwood6

Block Scoping and Constants in JavaScript ES6: let and const

The let Declaration Basic Usage The let keyword introduces block-scoped variables. Unlike var, variables declared with let are not accessible outside their containing block. // Example with var { var globalVar = 'leaks'; } console.log(globalVar); // Outputs: leaks // Example with let { let blockScoped = 'does not leak'; } console.log(block ...

Posted on Sun, 10 May 2026 22:47:34 +0000 by Adam W