Tutorial by Examples: c

A common use of member functions is for encapsulation, using an accessor (commonly known as a getter) and a mutator (commonly known as a setter) instead of accessing fields directly. class Encapsulator { int encapsulated; public: int get_encapsulated() const { return encapsulated; }...
Member functions can also be declared virtual. In this case, if called on a pointer or reference to an instance, they will not be accessed directly; rather, they will look up the function in the virtual function table (a list of pointers-to-member-functions for virtual functions, more commonly know...
One of the primary uses for this cv-qualifiers is const correctness. This is the practice of guaranteeing that only accesses that need to modify an object are able to modify the object, and that any (member or non-member) function that doesn't need to modify an object doesn't have write access to t...
Starting a DSC on a remote machine is almost just as simple. Assuming you've already set up Powershell remoting (or enabled WSMAN). $remoteComputer = "myserver.somedomain.com" $cred = (Get-Credential) Start-DSCConfiguration -ServerName $remoteComputer -Credential $cred -Verbose Nb: A...
Sometimes it can be useful to test your Powershell data files and iterate through the nodes and servers. Powershell 5 (WMF5) added this neat little feature for doing this called Import-PowerShellDataFile . Example: $data = Import-PowerShellDataFile -path .\MydataFile.psd1 $data.AllNodes
To list available DSC resources on your authoring node: Get-DscResource This will list all resources for all installed modules (that are in your PSModulePath) on your authoring node. To list all available DSC resources that can be found in the online sources (PSGallery ++) on WMF 5 : Find-DS...
Before you can use a resource in a configuration, you must explicitly import it. Just having it installed on your computer, will not let you use the resource implicitly. Import a resource by using Import-DscResource . Example showing how to import the PSDesiredStateConfiguration resource and the F...
#!/usr/bin/env python """ An annotated simple socket client example in python. WARNING: This example doesn't show a very important aspect of TCP - TCP doesn't preserve message boundaries. Please refer to http://blog.stephencleary.com/2009/04/message-framing.html before adaptin...
Apart from primitives, the Explicit Layout structs (Unions) in C#, can also contain other Structs. As long as a field is a Value type and not a Reference, it can be contained in a Union: using System; using System.Runtime.InteropServices; // The struct needs to be annotated as "Explici...
Signing a script is done by using the Set-AuthenticodeSignature-cmdlet and a code-signing certificate. #Get the first available personal code-signing certificate for the logged on user $cert = @(Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert)[0] #Sign script using certificate Se...
To change the execution policy for the default scope (LocalMachine), use: Set-ExecutionPolicy AllSigned To change the policy for a specific scope, use: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy AllSigned You can suppress the prompts by adding the -Force switch.
Often you might need to execute an unsigned script that doesn't comply with the current execution policy. An easy way to do this is by bypassing the execution policy for that single process. Example: powershell.exe -ExecutionPolicy Bypass -File C:\MyUnsignedScript.ps1 Or you can use the shorthan...
Getting the effective execution policy for the current session: PS> Get-ExecutionPolicy RemoteSigned List all effective execution policies for the current session: PS> Get-ExecutionPolicy -List Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined...
Get information about the Authenticode signature from a signed script by using the Get-AuthenticodeSignature-cmdlet: Get-AuthenticodeSignature .\MyScript.ps1 | Format-List *
When signing personal scripts or when testing code signing it can be useful to create a self-signed code signing certificate. 5.0 Beginning with PowerShell 5.0 you can generate a self-signed code signing certificate by using the New-SelfSignedCertificate-cmdlet: New-SelfSignedCertificate -Friendl...
Dynamic SQL enables us to generate and run SQL statements at run time. Dynamic SQL is needed when our SQL statements contains identifier that may change at different compile times. Simple Example of dynamic SQL: CREATE PROC sp_dynamicSQL @table_name NVARCHAR(20), @col_name NVARCHAR(2...
import XCTest @testable import PersonApp class PersonTests: XCTestCase { func test_completeName() { let person = Person(firstName: "Josh", lastName: "Brown") XCTAssertEqual(person.completeName(), "Josh Brown") } } Now let's discuss wh...
The normal Java classloaders look for classes first in the bootstrap classpath, before checking for extensions and the application classpath. By default, the bootstrap classpath consists of the "rt.jar" file and some other important JAR files that are supplied by the JRE installation. Th...
Unity networking provides the High Level API (HLA) to handle network communications abstracting from low level implementations. In this example we will see how to create a Server that can communicate with one or multiple clients. The HLA allows us to easily serialize a class and send objects of ...
Pre-requisites: cx_Oracle package - See here for all versions Oracle instant client - For Windows x64, Linux x64 Setup: Install the cx_Oracle package as: sudo rpm -i <YOUR_PACKAGE_FILENAME> Extract the Oracle instant client and set environment variables as: ORACLE_HOME=&...

Page 489 of 826