While Switching to C++ (edited)

**** UPDATED POST ****

Yesterday I was under the impression that all was well with the updates on my Windows 10 development computer. To learn more about it take a look at the section labeled ORIGINAL POST in this entry.

After tinkering with the issue for a couple hours, it seemed like when I restarted my machine the Shut down or sign out menu did not display the update and restart or the update and shutdown sub menu items.

This morning after starting my machine, I took a look at the Shut down or sign out menu. The update and restart and the update and shutdown sub menus were back. I restarted the computer to eliminate the possibility that a new update had just been released. That was not the case.

I took a look at the Settings -> Update & Security screen. The following update was ready to be installed:

Microsoft .NET Framework 4.7 for Windows 10 Version 1607 and Windows Server 2016 for x64 (KB3186568).

I tried Windows Update and other options. I restarted my machine a few times. The update remained pending.

At that time I used Google to find options to address the issue. Found an article that suggested the following steps:

In File Explorer, open C:\Windows\System32\Tasks\Microsoft.

(You might need to click a consent dialog box to gain access to this folder.)

Delete the entire XblGameSave subfolder.

Using Registry Editor, delete the following key:



Gave it a try and restarted my machine. The update started around 07:50 AM CDT. After the machine automatically restarted several times and I logged to it once, the update completed around 11:30 AM CDT. The morning was pretty much done.

I took a look at the Settings -> Update & Security screen. The display now read:

No updates are available. We’ll continue to check daily for newer updates.

Between yesterday and today I spent / wasted about six hours with the Windows 10 update. If you do the math taking into account the number of computers that have and will be affected with this issue, many people could have taken a day of vacation!!!


In the previous post More Emphasis on C++ I mentioned that periodically I switch programming languages based on what I am working on. In the past weeks I have been getting ready to start work on a new project. The main programming language for it will be C++.

When I start working on a new project I like to take some time to review and learn new things and techniques about the programming language, development tools and the domain of the project. I am a morning person so I wake up relatively early. Today it was no exception. I woke up around 04:00 AM and spent half hour or so reading. When done, I decided to go down to my office and get some work done. My wife and I have breakfast every day around 06:00 AM. If she wakes up too early her day does not go well for her (or for me).

For the past couple days I have been watching for a second time a set of DVDs on C++ that I purchase a few years ago. The first video I watched today had to do with passing arguments to functions. The example was based on swapping integers.  Not too long ago I wrote the Swap Values post using a similar example.  Because of that, I revisited the C++ and Java code that I used for that post.

Java passes arguments by value and not by reference. C++ is able to pass arguments by value or by reference.

Following is a screen capture of the console of the Eclipse neon.3 IDE showing the output of the updated Java code:

main <<< a: 3
main <<< b: 4
main <<< a: 3 b: 4

main <<< swap() a: 3 b: 4
main <<< Swap() aa: 3 bb: 4
main <<< swapPublic() a: 4 b: 3
main <<< myNumbers.swap() a: 4 b: 3
main <<< arr[0]: 4 arr[1]: 3

The updated Java source code follows:

import java.util.Scanner;

 * Auxiliary class holding members to be swapped.
class MyNumbers {

	// **** could have been made private ****
	public int a;
	public int b;
	 * Swap the members.
	public void swap () {
		int temp 	= this.a;
		this.a 		= this.b;
		this.b 		= temp;

public class Solution {
	 * Swap auxiliary class members.
	static void swapPublic (MyNumbers numbers) {
		int temp 	= numbers.a;
		numbers.a 	= numbers.b;
		numbers.b 	= temp;

	 * Swap entries in the array.
	static void SwapArray(int[] arr) {
		int length = arr.length;
		if (length < 2) {
			System.out.println("SwapArray <<< UNEXPECTED length: " + length);
		int temp 	= arr[0];
		arr[0] 		= arr[1];
		arr[1] 		= temp;
	 * Swap two Integers.
	public static void Swap(Integer aa, Integer bb) {
		Integer temp 	= aa;
		aa 				= bb;
		bb 				= temp;
	 * Swap two integers.
	public static void swap(int a, int b) {
		int temp 	= a;
		a 			= b;
		b 			= temp;

	 * Test code.
	public static void main(String[] args) {

		// **** ****
		Scanner sc = new Scanner(System.in);
		// **** ****
		System.out.print("main <<< a: ");
		int a = sc.nextInt();
		System.out.print("main <<< b: ");
		int b = sc.nextInt();

		// ***** display initial values ****
		System.out.println("main <<< a: " + a + " b: " + b);

		// ***** close scanner ****
		// **** swap the integers ****
		swap(a, b);
		// **** display swapped values ****
		System.out.println("main <<< swap() a: " + a + " b: " + b);
		// **** swap objects (Integers are immutable objects) ****
//		Integer aa = a;
		Integer aa = new Integer(a);
//		Integer bb = b;
		Integer bb = new Integer(b);
		Swap(aa, bb);
		System.out.println("main <<< Swap() aa: " + aa + " bb: " + bb);
		// **** elements of an auxiliary class ****
		MyNumbers myNumbers = new MyNumbers();
		myNumbers.a = a;
		myNumbers.b = b;
		System.out.println("main <<< swapPublic() a: " + myNumbers.a + " b: " + myNumbers.b);
		// **** swap method in auxiliary class ****
		myNumbers.a = a;
		myNumbers.b = b;
		System.out.println("main <<< myNumbers.swap() a: " + myNumbers.a + " b: " + myNumbers.b);
		// **** swap array elements ****
		int[] arr = new int[2];
		arr[0] = a;
		arr[1] = b;
		System.out.println("main <<< arr[0]: " + arr[0] + " arr[1]: " + arr[1]);

Note that a few more approaches have been added to swap the integers. The conclusion:  Java passes arguments by value.

Following is a screen capture of a console showing the output of a C++ program:

num1: 3
num2: 4
num1: 4 num2: 3
num1: 3 num2: 4

The swap operation is simple and easy to implement.

Following is the C++ code that I generated using Visual Studio 2017 Enterprise Edition:

#include <iostream>

using namespace std;

Parameters are passed by reference.
void swap (int &num1, int &num2) {
	int temp	= num1;
	num1		= num2;
	num2		= temp;

int main () {

	int num1 = 0,
		num2 = 0;

	cout << "num1: "; cin >> num1;
	cout << "num2: "; cin >> num2;

	// **** swap them ****

	int temp	= num1;
	num1		= num2;
	num2		= temp;
	cout << "num1: " << num1 << " num2: " << num2 << endl;

	// **** swap them again (arguments by reference in function declaration) ****

	swap(num1, num2);
	cout << "num1: " << num1 << " num2: " << num2 << endl;

	// **** ****

	return 0;

The code is short, simple, elegant and easy to follow. Just by changing the decorators (&) on the arguments in the declaration of the swap() function, the code does what we need it to do.

If you have comments or questions regarding this or any other entry in this blog, please do not hesitate and leave me a comment. I will respond as soon as possible.



Follow me on Twitter:  @john_canessa

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.