Creating a User Account on Your Wi-Fi Network

Chances are you have two main reasons for setting up a home network: you want to share an Internet connection between your computers and you want to be able to copy files between computers. If you use a Mac and want to allow access to the network from Windows PCs, you must first create a Windows user account.

Follow these steps on the Mac to create the Windows user account:

1. Open System Preferences from the Apple menu.

2. Click the Accounts icon to open the Accounts window.

3. Click New User (OS 10.3 and earlier) or the plus sign in the lower-left corner of the Accounts window (OS 10.4 and later).

4. Enter a name, short name, and password for the user (see Figure 1).

For example, you can name the account Windows to help you remember the purpose of the account later.




Figure 1: Name the Windows user account.

5. Select the Allow User to Log In from Windows check box if you see it.

As the name implies, this option enables users to log in using this account on Windows PCs. This option is not available (or required) in newer versions of Mac OS X.


6. Click Save or Create Account (depending on your OS X version) to save the new user account. The Windows account now appears in the list of user accounts, as shown in Figure 2.



Figure 2: The Windows account appears in the list.
Because Mac OS X is based on UNIX, user account names and passwords are case sensitive. Make sure that Windows users on your network know this, because if the user name is "Windows" and they try to log on using "windows," the log in attempt will be unsuccessful.

Sharing Folders on Wi-Fi Networks

Computer files are organized into folders on your hard drive. In Windows and Mac OS X, access to those folders is strictly controlled. If you own a folder, other computers on your network — and even other users on the same computer — can't access it. To copy files back and forth over the network, you can share folders with others.

Sharing a folder in Windows
Follow these steps to set up folder sharing in Windows:

1. Choose Start --> All Programs --> Accessories --> Communications --> Network Connections.

2. In the Network Connections window, right-click your network connection and choose Properties from the menu that appears.

3. In the Network Connection Properties dialog box, select the File and Printer Sharing for Microsoft Networks check box.

File and Printer Sharing may already be enabled on your computer, but you should double-check it to make sure.


4. Click OK to close the dialog box.

5. Open My Computer or Windows Explorer.

6. Locate the Shared Documents folder. Right-click the Shared Documents folder and choose Sharing and Security from the menu that appears.

7. In the resulting Properties dialog box, select the Share This Folder on the Network check box.

8. Type a descriptive name for the folder in the Share Name field.

9. Click OK to close the Properties dialog box.

10. To share files or folders, copy them into the Shared Documents folder using My Computer or Windows Explorer.

To create a new subfolder in the Shared Documents folder, open Shared Documents and then choose File --> New --> Folder. Give the new folder a descriptive name.


Accessing a shared network folder in Windows
To access a shared networks folder in Windows, follow these steps:

1. Choose Start --> My Network Places.

You can also access My Network Places from My Computer or Windows Explorer. In My Computer, click My Network Places under Other Places on the left side of the screen. In Windows Explorer, click My Network Places near the bottom of the folder tree on the left side of the screen.

2. In the My Network Places window that appears, double-click the network place that you want to open.

If you don't see a network folder that you think should be available, make sure that the computer containing the network folder is turned on and connected to the network. Also, double-check the file sharing settings on the other computer.


3. Browse the network folder.

4. To copy an item to a shared network folder, simply click and drag it to the shared folder's window. (You can also use Cut, Copy, and Paste commands when browsing shared network drives.)

When you share a folder, anyone on your network can access it. Do not store private or sensitive files in shared folders.


Enabling file sharing in OS X
If you are using a Mac, follow these steps to enable file sharing in Mac OS X:

1. Open System Preferences from the Apple menu and then click Sharing.

2. In the resulting Sharing control panel, provide a descriptive name for your computer. (Other computers will see this name over the network.)

3. Select the Personal File Sharing check box. If you will be sharing folders with Windows PCs, check the Windows File Sharing option as well.

4. Close the Sharing control panel.

These steps assume that you have Mac OS Version 10.2 or better. Windows File Sharing is only available in Mac OS 10.2 or better. Sharing files between Windows and older versions of Mac OS requires special third-party programs.


Changing the workgroup name in OS X
Follow these steps to change the workgroup name in Mac OS X.

1. Open the Applications folder on your hard drive and then open the Utilities subfolder.

2. Double-click the Directory Access utility to open it.

3. Click the lock icon at the bottom of the Directory Access utility and then enter an administrator name and password.

4. Select SMB/CIFS on the Services tab and then click the Configure button.

5. Enter your Windows workgroup name in the Workgroup field and click OK.

Choosing a Network Access Mode and Finding a Wireless Network

You can choose between three network access modes when locating available Wi-Fi networks within range of your computer. Each network access mode offers a different level of security.

After you've connected to a network, the Wireless Network Connection window enables you to manage your network connections. Using this window you can connect or disconnect from networks, or change the order of preferred networks when more than one is available.

Choosing a network access mode
Follow these steps to choose a network access mode:

1. Double-click the wireless connection icon in the Windows system tray (in the lower-right corner of the screen).

If you don't see a wireless connection icon in the system tray, choose Start --> All Programs --> Accessories --> Communications --> Network Connections. Right-click your wireless connection and choose Properties. Select the Show Icon in Notification Area When Connected check box and click OK.


2. In the Wireless Network Connection Status dialog box, click the Properties button.

3. In the Wireless Network Connection Properties dialog box, click the Wireless Networks tab.

4. Click the Advanced button to open the Advanced dialog box.

5. Choose a network access mode:

• Any Available Network (Access Point Preferred): The computer tries to connect to any wireless network that is detected.

• Access Point (Infrastructure) Networks Only: The computer tries to connect to networks using a wireless access point. This setting gives you more security, especially at Wi-Fi hotspots.

• Computer-to-Computer (Ad Hoc) Networks Only: The computer tries to connect to other computers, called ad hoc networking.

6. If you want to automatically log on to any available wireless network, select the Automatically Connect to Non-Preferred Networks check box.

Automatically logging on to any available network could leave your computer vulnerable to unknown and untrusted networks. Do not enable this option if your computer contains sensitive or personal information.


7. Click Close to close the Advanced dialog box and click OK to close all remaining dialog boxes.

Searching for wireless networks
Use these steps to search for a wireless network within range of your computer:

1. Double-click the wireless connection icon in the Windows system tray.

2. In the Wireless Network Connection Status dialog box, click the View Wireless Networks button.

3. In the resulting Wireless Network Connection window, click Refresh Network List in the Network Tasks menu on the left side of the screen.

Checking Out the Visual Basic .NET User Interface

Because a computer monitor can display only a limited amount of information on the screen at any given time, Visual Basic .NET provides several different windows for displaying vital information about your Visual Basic .NET program. After you understand the purpose of each window, you can use some of the following tips listed to make programming in Visual Basic .NET easier than before.

Playing with the Properties Windows (F4)
The Properties window enables you to modify the way objects, such as a button or a check box, look and behave. To help you find properties to change, the Properties window can display information alphabetically or by categories.

To display properties alphabetically, click on the Alphabetic icon in the Properties window. To display properties organized by category, click on the Categorized icon.

The Properties window displays all properties for a single object. If you want to view the properties for another object, you can click on that object or use the Object list box. Just click on the downward-pointing arrow of the Object list box to display a list of all objects and then click on the object that you want to modify.

Using the Solution Explorer (Ctrl+Alt+L)
The Solution Explorer displays all the files used to create a single Visual Basic .NET project. From within the Solution Explorer, you can edit a form, edit the code stored in a file, remove a file from a project, or delete that file altogether by right-clicking on the file you want to change and then clicking on one of the following:

View Code (to edit BASIC code)
View Designer (to modify your user interface)
Exclude From Project (to remove a file from the project without deleting that file)
Delete (to remove a file from a project and erase that file at the same time)
Customizing the Toolbox (Ctrl+Alt+X)
The Toolbox displays all the different types of objects you can add to your user interface such as radio buttons, check boxes, or text boxes, which are stored under the Windows Forms tab. For quick access to your most commonly used objects, you can create your own tab and store your favorite objects on that tab.

Customizing a Tab in the Toolbox
To create a tab in the Toolbox, follow these steps:

1. Right-click on any tab (such as the Windows Forms tab) in the Toolbox.

A pop-up menu appears.

2. Click on Add Tab.

The Toolbox displays a blank tab.

3. Type a descriptive name for your tab and press Enter.

The Toolbox displays your tab name in the Toolbox.

Adding Objects to a Custom Tab in the Toolbox
To add objects to your custom tab in the Toolbox, follow these steps:

1. Right-click on an object that you want, such as TextBox or RadioButton.

A pop-up menu appears.

2. Click on Copy.

3. Click on the tab where you want to store the object you chose in Step 1.

4. Right-click and choose Paste.

The Toolbox displays your chosen object under your Toolbox tab.

Deleting a Tab in the Toolbox
To delete a tab in the Toolbox, follow these steps:

1. Right-click on the tab you want to delete.

A pop-up menu appears.

2. Click on Delete Tab.

If you have any objects stored under your chosen tab, a dialog box appears, asking if you want to continue.

3. Click Yes.

Visual Basic .NET deletes your chosen Toolbox tab.

Looking at the Class View (Ctrl+Alt+C)
The Class View lists all the variables, methods, and properties used by class files that make up your Visual Basic .NET project. By using the Class View window, you can quickly jump to the part of a class file that you need to examine or modify.

To view a variable, method, or property, follow these steps:

1. Choose View --> Class View (or press Ctrl+Alt+C) to open the Class View window.

The Class View window appears.

2. Double-click on the variable, method, or property that you want to examine or modify.

Visual Basic .NET displays your chosen variable, method, or property in the Code Editor.

Avoiding Bugs in Your C++ Program

Don't start debugging your code until you remove or at least understand all the warnings generated during compilation. Enabling all the warning messages if you then ignore them does you no good. If you don't understand the warning, look it up. What you don't know will hurt you.

Adopt a clear and consistent coding style
Coding in a clear and consistent style not only enhances the readability of the program but also results in fewer coding mistakes. Remember, the less brain power you have to spend deciphering C++ syntax, the more you have left over for thinking about the logic of the program at hand. A good coding style enables you to do the following with ease:

Differentiate class names, object names, and function names
Know something about the object based on its name
Differentiate preprocessor symbols from C++ symbols (that is, #defined objects should stand out)
Identify blocks of C++ code at the same level (this is the result of consistent indentation)
In addition, you need to establish a standard module header that provides information about the functions or classes in the module, the author (presumably, that's you), the date, the version of the compiler you're using, and a modification history.

Finally, all programmers involved in a single project should use the same style. Trying to decipher a program with a patchwork of different coding styles is confusing.


Comment your code as you write it
You can avoid errors if you comment your code while you write it rather than wait until everything works and then go back and add comments. Not taking the time to write voluminous headers and function descriptions until later is understandable, but you always have time to add short comments while writing the code.

Short comments should be enlightening. If they're not, they aren't worth much and you should be doing something else instead. You need all the enlightenment you can get while you're trying to make your program work. When you look at a piece of code you wrote a few days ago, comments that are short, descriptive, and to the point can make a dramatic contribution to helping you figure out exactly what it was you were trying to do.

In addition, consistent code indentation and naming conventions make the code easier to understand. It's all very nice when the code is easy to read after you're finished with it, but it's just as important that the code be easy to read while you're writing it. That's when you need the help.

Single-step every path at least once
As a programmer, it's important for you to understand what your program is doing. Nothing gives you a better feel for what's going on under the hood than single-stepping the program with a good debugger. (The debuggers included in the IDE of interactive compilers work just fine.)

Beyond that, as you write a program, you sometimes need raw material to figure out some bizarre behavior. Nothing gives you that material better than single-stepping new functions as they come into service.

Finally, when a function is finished and ready to be added to the program, every logical path needs to be traveled at least once. Bugs are much easier to find when the function is examined by itself rather than after it's been thrown into the pot with the rest of the functions — and your attention has gone on to new programming challenges.

Avoid overloading operators
Other than using the two stream I/O operators operator<<() and operator>>() and the assignment operator operator=(), you should probably hold off overloading operators until you feel comfortable with C++. Although a good set of overloaded operators can increase the utility and readability of a new class, overloading operators (other than the three just listed) is almost never necessary and can add significantly to your debugging woes as a new programmer. You can get the same effect by defining and using the proper public member functions instead.

After you've been C-Plus-Plussing for a few months, feel free to return and start overloading operators to your heart's content.

Balance heap handling
Generally, programmers should allocate and release heap memory at the same "level." If a member function MyClass::create() allocates a block of heap memory and returns it to the caller, then there should be a member function MyClass::release() that returns the memory to the heap. Specifically, MyClass::create() should not require the parent function to release the memory itself. This certainly doesn't avoid all memory problems — the parent function may forget to call MyClass::release() — but it does reduce the possibility somewhat.

Use exceptions to handle errors
The exception mechanism in C++ is designed to handle errors conveniently and efficiently. Now that this feature has been standardized, you should use it. The resulting code is easier to write, easier to read, and easier to maintain. Besides, other programmers have come to expect it — you wouldn't want to disappoint them, would you?

Avoid multiple inheritance
Multiple inheritance, like operator overloading, adds another level of complexity that you don't need to deal with when you're just starting out. Fortunately, most real-world relationships can be described with single inheritance.

Feel free to use multiple-inherited classes from commercial libraries, such as the Microsoft MFC classes. Microsoft has spent a considerable amount of time setting up its classes, and it knows what it's doing.

After you feel comfortable with your level of understanding of C++, experiment with setting up some multiple inheritance hierarchies. That way, you'll be ready if you need it.

Working with Functions in C++

Developers often need the ability to break programs up into smaller chunks that are easier to develop. "Real world" programs can be many of thousands (or millions!) of lines long. Without this ability to divide the program into parts, developing such large programs would quickly become impossible.

C++ allows programmers to divide their code up into chunks known as functions. A function with a simple description and a well-defined interface to the outside world can be written and debugged without worrying about the code that surrounds it.

Overloading function names
C++ allows the programmer to assign the same name to two or more functions. This multiple use of names is known as overloading functions or, simply, overloading.

In general, two functions in a single program cannot share the same name. If they did, C++ would have no way to distinguish them.

However, the name of the function includes the number and type of its arguments. (The name of the function does not include its return argument.) Thus, the following are not the same functions:

void someFunction(void)
{
// ....perform some function
}
void someFunction(int n)
{
// ...perform some different function
}
void someFunction(double d)
{
// ...perform some very different function
}
void someFunction(int n1, int n2)
{
// ....do something different yet
}

C++ still knows that the functions someFunction(void), someFunction(int), someFunction(double), and someFunction(int, int) are not the same. Like so many things that deal with computers, this has an analogy in the human world.

void as an argument type is optional. sumFunction(void) and sumFunction() are the same function. A function has a shorthand name, such as someFunction(). As long as we use the entire name, no one gets confused — no matter how many someFunctions there may be. The full name for one of the someFunctions()is someFunction(int). As long as this full name is unique, no confusion occurs.

A typical application may appear as follows:

int intVariable1, intVariable2; // equivalent to
// int Variable1;
// int Variable2;
double doubleVariable;
// functions are distinguished by the type of
// the argument passed
someFunction(); // calls someFunction(void)
someFunction(intVariable1); // calls someFunction(int)
someFunction(doubleVariable); // calls someFunction(double)
someFunction(intVariable1, intVariable2); // calls
// someFunction(int, int)
// this works for constants as well
someFunction(1); // calls someFunction(int)
someFunction(1.0); // calls someFunction(double)
someFunction(1, 2); // calls someFunction(int, int)

In each case, the type of the arguments matches the full name of the three functions.

The return type is not part of the extended name (also known as the function signature) of the function. The following two functions have the same name and, thus, cannot be part of the same program:


int someFunction(int n); // full name of the function
// is someFunction(int)
double someFunction(int n); // same name

The following is acceptable:


int someFunction(int n);
double d = someFunction(10); // promote returned value

The int returned by someFunction() is promoted into a double. Thus, the following would be confusing:

int someFunction(int n);
double someFunction(int n);
double d = someFunction(10);// promote returned int?
// or use returned double as is

C++ would know whether to use the value returned from the double version of someFunction() or promote the value returned from int version.

Defining function prototypes
The programmer may provide the remainder of a C++ source file, or module, the extended name (the name and functions) during the definition of the function.

A function may be defined anywhere in the module. (A module is another name for a C++ source file.) However, something has to tell main() the full name of the function before it can be called. Consider the following code snippet:

int main(int argc, char* pArgs[])
{
someFunc(1, 2);
}
int someFunc(double arg1, int arg2)
{
// ...do something
}

The call to someFunc() from within main() doesn't know the full name of the function. It may surmise from the arguments that the name is someFunc(int, int) and that its return type is void; however, as you can see, this is incorrect.

C++ could be less lazy and look ahead to determine the full name of someFunc()s on its own, but it doesn't. What is needed is some way to inform main() of the full name of someFunc() before it is used. What is needed is a before use function declaration. Some type of prototype is necessary.

A prototype declaration appears the same as a function with no body. In use, a prototype declaration appears as follows:

int someFunc(double, int);
int main(int argc, char* pArgs[])
{
someFunc(1, 2);
}
int someFunc(double arg1, int arg2)
{
// ...do something
}

The prototype declaration tells the world (at least that part of the world after the declaration), that the extended name for someFunc() is someFunction(double, int). The call in main() now knows to cast the 1 to a double before making the call. In addition, main() knows that the value returned by someFunc() is an int.

A function call that returns a value is an expression. As with any other provide expression, you are allowed to throw the value returned by a function.


Variable storage types
Function variables are stored in three different places. Variables declared within a function are said to be local. In the following example, the variable localVariable is local to the function fn():

int globalVariable;
void fn()
{
int localVariable;
static int staticVariable;
}

The variable localVariable doesn't exist until the function fn() is called. localVariable ceases to exist when the function returns. Upon return, whatever value that is stored in localVariable is lost. In addition, only fn() has access to localVariable — other functions cannot reach into the function to access it.

By comparison, the variable globalVariable exists as long as the program is running. All functions have access to globalVariable all of the time.

The static variable staticVariable is something of a mix between a local and a global variable. The variable staticVariable is created when execution first reaches the declaration (roughly, when the function fn() is called). In addition, staticVariable is only accessible within fn(). Unlike localVariable, however, staticVariable continues to exist even after the program returns from fn(). If fn() assigns a value to staticVariable once, it will still be there the next time that fn() is called.

In case anyone asks, there is a fourth type, auto, but today it has the same meaning as local, so just ignore them.

Expressing Binary Numbers in C++

C++ variables are stored internally as so-called binary numbers. Binary numbers are stored as a sequence of 1 and 0 values known as bits. Most of the time, you don't really need to deal with numbers at the bit level; however, there are occasions when doing so is convenient. C++ provides a set of operators for this purpose.

The so-called bitwise logical operators operate on their arguments at the bit level. To understand how they work, examine how computers store variables.

The decimal number system
The numbers that you are familiar with are known as decimal numbers because they are based on the number 10. In general, the programmer expresses C++ variables as decimal numbers. Thus, you would say that the value of var is 123, for example.

A number such as 123 refers to 1 * 100 + 2 * 10 + 3 * 1. Each of these base numbers — 100, 10, and 1 — is a power of 10.

123 = 1 * 100 + 2 * 10 + 3 * 1

Expressed in a slightly different but equivalent way:

123 = 1 * 102 + 2 * 101 + 3 * 100

Remember that any number to the zero power is 1.


Other number systems
The use of a base number of 10 for the counting system stems, in all probability, from the fact that humans have 10 fingers, the original counting tools. The alternative would have been base 20.

If dogs had invented our numbering scheme, it may well have been based on the numeral 8 (one digit of each paw is out of sight on the back part of the leg). Such an octal system would have worked just as well:

12310 = 1 * 82 + 7 * 81 + 3 * 80 = 1738

The small 10 and 8 here refer to the numbering system, 10 for decimal (base 10) and 8 for octal (base 8). A counting system may use any positive base.

The binary number system
Computers have essentially two fingers. (Maybe that's why computers are so stupid: Without an opposable thumb, they can't grasp anything. And then again, maybe not.) Computers prefer counting using base 2. The number 12310 would be expressed as:

12310 = 0*128 + 1*64 + 1*32 + 1*16 + 1*8 + 0*4 +1*2 + 1*1
= 011110112

It is always convention to express binary numbers by using 4, 8, 32, or 64 binary digits even if the leading digits are zero. This is also because of the way computers are built internally.

Because the term digit refers to a multiple of ten, a binary digit is called a bit. The term stems from binary (b-) digit (-it). Eight bits make up a byte. A word is usually either two or four bytes.


With such a small base, it is necessary to use a large number of bits to express numbers. It is inconvenient to use an expression such as 011110112 to express such a mundane value as 12310. Programmers prefer to express numbers by units of bytes, or eight bits.

A single, four-bit digit is essentially base 16, because four bits can express up to any value from 0 to 15. Base 16 is known as the hexadecimal counting system. Hexadecimal is often contracted to simply hex.

Hexadecimal uses the same digits for the numbers 0 through 9. For the digits between 9 and 16, hexadecimal uses the first six letters of the alphabet: A for 10, B for 11, and so on. Thus, 12310 becomes 7B16.

123 = 7 * 161 + B (i.e., 11) * 160 = 7B16

Because programmers prefer to express numbers in 4, 8, 32, or 64 bits, they similarly prefer to express hexadecimal numbers in 1, 2, 4, or 8 hexadecimal digits even when the leading digits are 0.

Finally, it is inconvenient to express a hexadecimal number such as 7B16 using a subscript, because terminals don't support subscripts. Even on a word processor, it is inconvenient to change fonts to and from subscript mode just to type two digits. Therefore, programmers use the convention of beginning a hexadecimal number with a 0x (the reason for such a strange conviction goes back to the early days of C). Thus, 7B becomes 0x7B. Using this convention, 0x7B is equal to 123 (while 0x123 is equal to 291.)

All of the mathematical operators can be performed on hexadecimal numbers in the same way that they are applied to decimal numbers. The reason that we can't perform a multiplication such as 0xC * 0xE in our heads has more to do with the multiplication tables we learned in school than on any limitation in the number system.