Tutorial by Examples: sin

It is illegal to access a reference to an object that has gone out of scope or been otherwise destroyed. Such a reference is said to be dangling since it no longer refers to a valid object. #include <iostream> int& getX() { int x = 42; return x; } int main() { int& r...
Pair allows us to treat two objects as one object. Pairs can be easily constructed with the help of template function std::make_pair. Alternative way is to create pair and assign its elements (first and second) later. #include <iostream> #include <utility> int main() { std::p...
In pass by value of parameter passing to a method, actual parameter value is copied to formal parameter value. So actual parameter value will not change after returning from called function. @interface SwapClass : NSObject -(void) swap:(NSInteger)num1 andNum2:(NSInteger)num2; @end @impleme...
In pass by reference of parameter passing to a method, address of actual parameter is passed to formal parameter. So actual parameter value will be changed after returning from called function. @interface SwapClass : NSObject -(void) swap:(int)num1 andNum2:(int)num2; @end @implementation S...
While Python has an assert statement, the Python unit testing framework has better assertions specialized for tests: they are more informative on failures, and do not depend on the execution's debug mode. Perhaps the simplest assertion is assertTrue, which can be used like this: import unittest ...
PendingIntent pendingIntent = PendingIntent.getActivity(context, uniqueIntentId, intent, PendingIntent.FLAG_CANCEL_CURRENT); final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.remote_view_notification); remoteViews.setImageViewResource(R.id.remote...
For some use cases, you can use the using syntax to help define a custom scope. For example, you can define the following class to execute code in a specific culture. public class CultureContext : IDisposable { private readonly CultureInfo originalCulture; public CultureContext(string ...
UISplitViewController needs to the root view controller of your app’s window AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] self.window.ba...
Ionic uses Gulp, so install gulp-babel and gulp-plumber. npm install --save-dev gulp-babel gulp-plumber Add babel to gulpfile.js like so: //... var babel = require("gulp-babel"); var plumber = require("gulp-plumber"); var paths = { es6: ['./src/es6/*.js'], sass: ...
For example, in the sentence: That cake is extremely nice. The rules of the English language would make cake a noun, extremely an adverb that modifies the adjective nice, and through this analysis the meaning could be understood. However, this analysis is dependent on us recognising that the...
#include <elapsedMillis.h> void setup() { Serial.begin(115200); elapsedMillis msTimer; elapsedMicros usTimer; long int dt = 500; delay(dt); long int us = usTimer; long int ms = msTimer; Serial.print("delay(");Serial.print(dt);Serial.println(") to...
An example to perform login test based on Page object pattern: import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; /** * Class which models the view of Sign-In page */ publ...
Xamarin.Forms provide great mechanism for styling your cross-platforms application with global styles. In mobile world your application must be pretty and stand out from the other applications. One of this characters is Custom Fonts used in application. With power support of XAML Styling in Xamar...
This trick helps you select an element using the ID as a value for an attribute selector to avoid the high specificity of the ID selector. HTML: <div id="element">...</div> CSS #element { ... } /* High specificity will override many selectors */ [id="element&quo...
To perform a query in Apex, surround the query with square brackets. The result can be assigned to a list, or to a single object. List<Account> allAccounts = [SELECT Id, Name FROM Account]; Account oldestAccount = [SELECT Id, Name FROM Account ORDER BY CreatedDate LIMIT 1];
To reference a variable in a query, add a colon (:) before the variable name. Datetime targetDate = Datetime.now().addDays(-7); List<Lead> recentLeads = [SELECT Id FROM Lead WHERE CreatedDate > :targetDate]; string targetName = 'Unknown'; List<Contact> incompleteContacts = [SELE...
When assigning to a single object, a query that returns anything other than a single row will throw a QueryException. try { Account a = [SELECT Id FROM Account WHERE Name = 'Non-existent Account']; } catch (QueryException e) { // List has no rows for assignment to SObject } try { ...
One big problem is that valuable named routes is not supported by Express out of the box. Solution is to install supported third-party package, for example express-reverse: npm install express-reverse Plug it in your project: var app = require('express')(); require('express-reverse')(app); ...
The visitor Pattern can be used to traverse structures. class GraphVisitor; class Graph { public: class Node { using Link = std::set<Node>::iterator; std::set<Link> linkTo; public: void accept(GraphVisito...
import java.awt.AWTException; import java.awt.Robot; import java.awt.event.KeyEvent; public class KeyBoardExample { public static void main(String[] args) { try { Robot robot = new Robot(); robot.delay(3000); robot.keyPress(KeyEvent.VK_Q); //...

Page 80 of 161