Tutorial by Examples

An element can be cloned by invoking the cloneNode method on it. If the first parameter passed to cloneNode is true, the children of the original will also be cloned. var original = document.getElementsByTagName("li")[0]; var clone = original.cloneNode(true);
CREATE TABLE Employees ( Id int NOT NULL, PRIMARY KEY (Id), ... ); This will create the Employees table with 'Id' as its primary key. The primary key can be used to uniquely identify the rows of a table. Only one primary key is allowed per table. A key can also be composed by one...
Many databases allow to make the primary key value automatically increment when a new key is added. This ensures that every key is different. MySQL CREATE TABLE Employees ( Id int NOT NULL AUTO_INCREMENT, PRIMARY KEY (Id) ); PostgreSQL CREATE TABLE Employees ( Id SERIAL PRIMARY...
This will draw a line at the bottom of every view but the last to act as a separator between items. public class SeparatorDecoration extends RecyclerView.ItemDecoration { private final Paint mPaint; private final int mAlpha; public SeparatorDecoration(@ColorInt int color, float w...
A class is a user-defined type. A class is introduced with the class, struct or union keyword. In colloquial usage, the term "class" usually refers only to non-union classes. A class is a collection of class members, which can be: member variables (also called "fields"), mem...
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...
The class template std::shared_ptr defines a shared pointer that is able to share ownership of an object with other shared pointers. This contrasts to std::unique_ptr which represents exclusive ownership. The sharing behavior is implemented through a technique known as reference counting, where the...
Instances of std::weak_ptr can point to objects owned by instances of std::shared_ptr while only becoming temporary owners themselves. This means that weak pointers do not alter the object's reference count and therefore do not prevent an object's deletion if all of the object's shared pointers are ...
Function overloading is having multiple functions declared in the same scope with the exact same name exist in the same place (known as scope) differing only in their signature, meaning the arguments they accept. Suppose you are writing a series of functions for generalized printing capabilities, b...
A std::vector can be initialized in several ways while declaring it: C++11 std::vector<int> v{ 1, 2, 3 }; // v becomes {1, 2, 3} // Different from std::vector<int> v(3, 6) std::vector<int> v{ 3, 6 }; // v becomes {3, 6} // Different from std::vector<int> v{3, ...
Appending an element at the end of a vector (by copying/moving): struct Point { double x, y; Point(double x, double y) : x(x), y(y) {} }; std::vector<Point> v; Point p(10.0, 2.0); v.push_back(p); // p is copied into the vector. C++11 Appending an element at the end of a vector ...
You can iterate over a std::vector in several ways. For each of the following sections, v is defined as follows: std::vector<int> v; Iterating in the Forward Direction C++11 // Range based for for(const auto& value: v) { std::cout << value << "\n"; } /...
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...
There are several ways to use a std::vector as a C array (for example, for compatibility with C libraries). This is possible because the elements in a vector are stored contiguously. C++11 std::vector<int> v{ 1, 2, 3 }; int* p = v.data(); In contrast to solutions based on previous C++ st...
The jQuery function (usually aliased as $) can be used both to select elements and to create new elements. var myLink = $('<a href="http://stackexchange.com"></a>'); You can optionally pass a second argument with element attributes: var myLink = $('<a>', { 'href': 'h...
Assuming the page includes an HTML element like: <p class="small-paragraph"> This is a small <a href="https://en.wikipedia.org/wiki/Paragraph">paragraph</a> with a <a class="trusted" href="http://stackexchange.com">link</a>...
To get started with the jQuery UI library, you'll need to add the jQuery script, the jQuery UI script, and the jQuery UI stylesheet to your HTML. First, download jQuery UI; choose the features you need on the download page. Unzip your download, and put jquery-ui.css and jquery-ui.js (and jquery.js)...

Page 62 of 1336