Tutorial by Examples: er

Converting between encodings is easy with C++11 and most compilers are able to deal with it in a cross-platform manner through <codecvt> and <locale> headers. #include <iostream> #include <codecvt> #include <locale> #include <string> using namespace std; i...
C++14 In C++14, this is easily done by std::mismatch which returns the first mismatching pair from two ranges: std::string prefix = "foo"; std::string string = "foobar"; bool isPrefix = std::mismatch(prefix.begin(), prefix.end(), string.begin(), string.end()).first == ...
The protected internal keyword marks field, methods, properties and nested classes for use inside the same assembly or derived classes in another assembly: Assembly 1 public class Foo { public string MyPublicProperty { get; set; } protected internal string MyProtectedInternalPropert...
std::ostringstream can be used to convert any streamable type to a string representation, by inserting the object into a std::ostringstream object (with the stream insertion operator <<) and then converting the whole std::ostringstream to a std::string. For int for instance: #include <sst...
Below is a recursive code to reverse a string /** * Just a snippet to explain the idea of recursion * **/ public class Reverse { public static void main (String args[]) { String string = "hello world"; System.out.println(reverse(string)); //prints dlrow oll...
A pointer (resp. reference) to an object type can be converted to a pointer (resp. reference) to any other object type using reinterpret_cast. This does not call any constructors or conversion functions. int x = 42; char* p = static_cast<char*>(&x); // error: static_cast cannot perf...
Default behavior when cloning an object is to perform a shallow copy of the object's fields. In that case, both the original object and the cloned object, hold references to the same objects. This example shows that behavior. import java.util.List; public class Sheep implements Cloneable { ...
To copy nested objects, a deep copy must be performed, as shown in this example. import java.util.ArrayList; import java.util.List; public class Sheep implements Cloneable { private String name; private int weight; private List<Sheep> children; public Sheep(Str...
Exceptions represent programmer-level bugs like trying to access an array element that doesn’t exist. Errors are user-level issues like trying load a file that doesn’t exist. Because errors are expected during the normal execution of a program. Example: NSArray *inventory = @[@"Sam"...
Before we download and install Composer, we need to make sure our server has all dependencies installed. First, update the package manager cache by running: sudo apt-get update Now, let's install the dependencies. We'll need curl in order to download Composer and php5-cli for installing and run...
Using raw values directly from the accelerometer sensor to move or rotate a GameObject can cause problems such as jerky movements or vibrations. It is recommended to smooth out the values before using them. In fact, values from the accelerometer sensor should always be smoothed out before use. This ...
First make utility class or use this method in class needed public class UIUtils { public static BitmapImageViewTarget getRoundedImageTarget(@NonNull final Context context, @NonNull final ImageView imageView, final float radius) { retur...
The following examples will use this class hierarchy: struct A { int m; }; struct B : A {}; struct C : B {}; The conversion from derived class type to base class type is preferred to user-defined conversions. This applies when passing by value or by reference, as well as when converting pointe...
Warning: The functions atoi, atol, atoll and atof are inherently unsafe, because: If the value of the result cannot be represented, the behavior is undefined. (7.20.1p1) #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { int val; if (argc < 2) ...
The contents of files and network messages may represent encoded characters. They often need to be converted to unicode for proper display. In Python 2, you may need to convert str data to Unicode characters. The default ('', "", etc.) is an ASCII string, with any values outside of ASCII ...
ABAP offers three different operators for declaring string- or char-like-variables SymbolsInternal TypeLengthName'...'C1-255 Charstext field literals`...`CString0-255 Charstext string literals|...|CString0-255 Charstemplate literals Note that the length-range only applies to hard coded values. Int...
$ jekyll build # The current site folder will be built into the ./_site directory $ jekyll build --destination /var/www/ # The current site folder will be generated into /var/www/ $ jekyll build --watch # The current site folder will be built into the ./_site directory and will be kept up t...
Use a HashMap to store the parameters that should be sent to the server through POST parameters: HashMap<String, String> params; Once the params HashMap is populated, create the StringBuilder that will be used to send them to the server: StringBuilder sbParams = new StringBuilder(); ...
VBA is compiled in run-time, which has a huge negative impact on it's performance, everything built-in will be faster, try to use them. As an example I'm comparing SUM and COUNTIF functions, but you can use if for anything you can solve with WorkSheetFunctions. A first attempt for those would be t...
Although available, defining a class from scratch is not recommended in modern Perl. Use one of helper OO systems which provide more features and convenience. Among these systems are: Moose - inspired by Perl 6 OO design Class::Accessor - a lightweight alternative to Moose Class::Tiny...

Page 149 of 417