Tutorial by Examples: ce

A useful feature of namespaces is that you can expand them (add members to it). namespace Foo { void bar() {} } //some other stuff namespace Foo { void bar2() {} }
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...
Classes/structs can have inheritance relations. If a class/struct B inherits from a class/struct A, this means that B has as a parent A. We say that B is a derived class/struct from A, and A is the base class/struct. struct A { public: int p1; protected: int p2; private: int p3;...
When using inheritance, you can specify the virtual keyword: struct A{}; struct B: public virtual A{}; When class B has virtual base A it means that A will reside in most derived class of inheritance tree, and thus that most derived class is also responsible for initializing that virtual base: ...
Aside from single inheritance: class A {}; class B : public A {}; You can also have multiple inheritance: class A {}; class B {}; class C : public A, public B {}; C will now have inherit from A and B at the same time. Note: this can lead to ambiguity if the same names are used in multipl...
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...
If you don't want to add Unix commands to your PATH on Windows, you can download a standalone SSH client like PuTTY. Download PuTTY here, then follow the instructions below to get a build machine. Call meteor admin get-machine <os-architecture> --json Copy and save the private key from the...
<?php ob_start(); ?> <html> <head> <title>Example invoice</title> </head> <body> <h1>Invoice #0000</h1> <h2>Cost: £15,000</h2> ... </body> </html> <?php...
import multiprocessing def fib(n): """computing the Fibonacci in an inefficient way was chosen to slow down the CPU.""" if n <= 2: return 1 else: return fib(n-1)+fib(n-2) p = multiprocessing.Pool() print(p.map(fib,[38,37,3...
This is an enum that is also a callable function that tests String inputs against precompiled regular expression patterns. import java.util.function.Predicate; import java.util.regex.Pattern; enum RegEx implements Predicate<String> { UPPER("[A-Z]+"), LOWER("[a-z]+&quot...
The following C source file (which we will call hello.c for demonstration purposes) produces an extension module named hello that contains a single function greet(): #include <Python.h> #include <stdio.h> #if PY_MAJOR_VERSION >= 3 #define IS_PY3K #endif static PyObject *hell...
When an exception object is created (i.e. when you new it), the Throwable constructor captures information about the context in which the exception was created. Later on, this information can be output in the form of a stacktrace, which can be used to help diagnose the problem that caused the excep...
#include <stdio.h> #define is_const_int(x) _Generic((&x), \ const int *: "a const int", \ int *: "a non-const int", \ default: "of other type") int main(void) { const int i = 1; int j = 1; double...
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...
Preferences objects always represent a specific node in a whole Preferences tree, kind of like this: /userRoot ├── com │   └── mycompany │   └── myapp │   ├── darkApplicationMode=true │   ├── showExitConfirmation=false │   └── windowMaximized=true └── org └...
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...
Preferences nodes can be exported into a XML document representing that node. The resulting XML tree can be imported again. The resulting XML document will remember whether it was exported from the user or system Preferences. To export a single node, but not its child nodes: Java SE 7 try (Output...
Preferences nodes can be imported from a XML document. Importing is meant to be used in conjunction with the exporting functionality of Preferences, since it creates the correct corresponding XML documents. The XML documents will remember whether they were exported from the user or system Preferenc...
A value of a Preferences node can be of the type String, boolean, byte[], double, float, int or long. All invocations must provide a default value, in case the specified value is not present in the Preferences node. Preferences preferences = Preferences.userNodeForPackage(getClass()); String som...
To store a value into the Preferences node, one of the putXXX() methods is used. A value of a Preferences node can be of the type String, boolean, byte[], double, float, int or long. Preferences preferences = Preferences.userNodeForPackage(getClass()); preferences.put("someKey", "...

Page 8 of 134