Tutorial by Examples: c

Expressions in C++ are assigned a particular value category, based on the result of those expressions. Value categories for expressions can affect C++ function overload resolution. Value categories determines two important-but-separate properties about an expression. One property is whether the exp...
You can see what "hunks" of work would be staged for commit using the patch flag: git add -p or git add --patch This opens an interactive prompt that allows you to look at the diffs and let you decide whether you want to include them or not. Stage this hunk [y,n,q,a,d,/,s,e,?]? ...
In this example, we illustrate string manipulation in MATLAB MEX. We will create a MEX-function that accepts a string as input from MATLAB, copy the data into C-string, modify it and convert it back to mxArray returned to the MATLAB side. The main objective of this example is to show how strings ca...
Since anonymous types are not named, variables of those types must be implicitly typed (var). var anon = new { Foo = 1, Bar = 2 }; // anon.Foo == 1 // anon.Bar == 2 If the member names are not specified, they are set to the name of the property/variable used to initialize the object. int foo ...
Anonymous types allow the creation of objects without having to explicitly define their types ahead of time, while maintaining static type checking. var anon = new { Value = 1 }; Console.WriteLine(anon.Id); // compile time error Conversely, dynamic has dynamic type checking, opting for runtime ...
Generic methods allow the use of anonymous types through type inference. void Log<T>(T obj) { // ... } Log(new { Value = 10 }); This means LINQ expressions can be used with anonymous types: var products = new[] { new { Amount = 10, Id = 0 }, new { Amount = 20, Id = 1 }, ...
Using generic constructors would require the anonymous types to be named, which is not possible. Alternatively, generic methods may be used to allow type inference to occur. var anon = new { Foo = 1, Bar = 2 }; var anon2 = new { Foo = 5, Bar = 10 }; List<T> CreateList<T>(params T[] it...
Arrays of anonymous types may be created with implicit typing. var arr = new[] { new { Id = 0 }, new { Id = 1 } };
To remove a cookie, set the expiry timestamp to a time in the past. This triggers the browser's removal mechanism: setcookie('user', '', time() - 3600, '/'); When deleting a cookie make sure the path and domain parameters of setcookie() matches the cookie you're trying to delete or a new cooki...
A view can be a really complex query(aggregations, joins, subqueries, etc). Just be sure you add column names for everything you select: Create VIEW dept_income AS SELECT d.Name as DepartmentName, sum(e.salary) as TotalSalary FROM Employees e JOIN Departments d on e.DepartmentId = d.id GROUP BY...
C11 C11 introduced support for multiple threads of execution, which affords the possibility of data races. A program contains a data race if an object in it is accessed1 by two different threads, where at least one of the accesses is non-atomic, at least one modifies the object, and program seman...
What is Serialization Serialization is the process of converting an object's state (including its references) to a sequence of bytes, as well as the process of rebuilding those bytes into a live object at some future time. Serialization is used when you want to persist the object. It is also used b...
The following syntax indicate that a class adopts a protocol, using angle brackets. @interface NewClass : NSObject <NewProtocol> ... @end This means that any instance of NewClass will respond to methods declared in its interface but also it will provide an implementation for all the requ...
The typeof operator works on type parameters. class NameGetter<T> { public string GetTypeName() { return typeof(T).Name; } }
toList flattens a Foldable structure t a into a list of as. ghci> toList [7, 2, 9] -- t ~ [] [7, 2, 9] ghci> toList (Right 'a') -- t ~ Either e "a" ghci> toList (Left "foo") -- t ~ Either String [] ghci> toList (3, True) -- t ~ (,) Int [True] toList is ...
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 works great most of the time, breezily reading aloud screens full of content and intuitively following the user. Alas, no general solution is perfect. Sometimes only you, the app developer, know where VoiceOver should be focused for an optimal user experience. Fortunately, VoiceOver listen...
In many cases, content within a single screen will update with new or different content. For example, imagine a form that reveals additional options based on the user’s answer to a previous question. In this case, a “layout change” notification lets you either announce the change or focus on a new e...
Announcements are useful for alerting users to events that don’t require any interaction, such as “screen locked” or “finished loading.” Use a more specific announcement to notify users of screen changes or more minor layout changes. UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotifi...

Page 63 of 826