Tutorial by Examples: access

There are three keywords that act as access specifiers. These limit the access to class members following the specifier, until another specifier changes the access level again: KeywordDescriptionpublicEveryone has accessprotectedOnly the class itself, derived classes and friends have accessprivate...
There are two primary ways of accessing elements in a std::vector index-based access iterators Index-based access: This can be done either with the subscript operator [], or the member function at(). Both return a reference to the element at the respective position in the std::vector (unles...
On an ext filesystem, each file has a stored Access, Modification, and (Status) Change time associated with it - to view this information you can use stat myFile.txt; using flags within find, we can search for files that were modified within a certain time range. To find files that have been modifi...
All instances of Preferences are always thread-safe across the threads of a single Java Virtual Machine (JVM). Because Preferences can be shared across multiple JVMs, there are special methods that deal with synchronizing changes across virtual machines. If you have an application which is supposed...
A a pointer to a piece of memory containing n elements may only be dereferenced if it is in the range memory and memory + (n - 1). Dereferencing a pointer outside of that range results in undefined behavior. As an example, consider the following code: int array[3]; int *beyond_array = array + 3; ...
The member access operators (dot . and arrow ->) are used to access a member of a struct. Member of object Evaluates into the lvalue denoting the object that is a member of the accessed object. struct MyStruct { int x; int y; }; struct MyStruct myObject; myObject.x = 42; myObj...
An std::map takes (key, value) pairs as input. Consider the following example of std::map initialization: std::map < std::string, int > ranking { std::make_pair("stackoverflow", 2), std::make_pair("docs-beta", 1) }; In an std::...
Reflection is often used as part of software testing, such as for the runtime creation/instantiation of mock objects. It's also great for inspecting the state of an object at any given point in time. Here's an example of using Reflection in a unit test to verify a protected class member contains the...
In classes, super.foo() will look in superclasses only. If you want to call a default implementation from a superinterface, you need to qualify super with the interface name: Fooable.super.foo(). public interface Fooable { default int foo() {return 3;} } public class A extends Object impl...
if [[ -r $filename ]]; then echo "$filename is a readable file" fi if [[ -w $filename ]]; then echo "$filename is a writable file" fi if [[ -x $filename ]]; then echo "$filename is an executable file" fi These tests take permissions and ownership into a...
NSArray *myColors = @[@"Red", @"Green", @"Blue", @"Yellow"]; // Preceding is the preferred equivalent to [NSArray arrayWithObjects:...] Getting a single item The objectAtIndex: method provides a single object. The first object in an NSArray is index 0. Si...
Mark your UIView subclass as an accessible element so that it is visible to VoiceOver. myView.isAccessibilityElement = YES; Ensure that the view speaks a meaningful label, value, and hint. Apple provides more details on how to choose good descriptions in the Accessibility Programming Guide.
The accessibility frame is used by VoiceOver for hit testing touches, drawing the VoiceOver cursor, and calculating where in the focused element to simulate a tap when the user double-taps the screen. Note that the frame is in screen coordinates! myElement.accessibilityFrame = frameInScreenCoordina...
VoiceOver can navigate many apps on iOS because most UIKit classes implement UIAccessibilityProtocol. Features that don’t represent onscreen elements using UIView, including apps that leverage Core Graphics or Metal to perform drawing, must describe these elements for accessibility. As of iOS 8.0, t...
To access tuple elements use Item1-Item8 properties. Only the properties with index number less or equal to tuple size are going to be available (i.e. one cannot access Item3 property in Tuple<T1,T2>). var tuple = new Tuple<string, int, bool, MyClass>("foo", 123, true, new MyC...
The Dim statement should be reserved for local variables. At module-level, prefer explicit access modifiers: Private for private fields, which can only be accessed within the module they're declared in. Public for public fields and global variables, which can be accessed by any calling code. Fr...
You can open the VB editor in any of the Microsoft Office applications by pressing Alt+F11 or going to the Developer tab and clicking on the "Visual Basic" button. If you don't see the Developer tab in the Ribbon, check if this is enabled. By default the Developer tab is disabled. To enab...
.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all su...
To access member variables and member functions of an object of a class, the . operator is used: struct SomeStruct { int a; int b; void foo() {} }; SomeStruct var; // Accessing member variable a in var. std::cout << var.a << std::endl; // Assigning member variable b in v...
Maps in go are not safe for concurrency. You must take a lock to read and write on them if you will be accessing them concurrently. Usually the best option is to use sync.RWMutex because you can have read and write locks. However, a sync.Mutex could also be used. type RWMap struct { sync.RWMut...

Page 2 of 12