Cover | Table of Contents | Colophon
#using <mscorlib.dll>
using namespace System;
void main( )
{
Console::WriteLine(L"C++ Hello, World!");
}
#using (shown in bold). If you have
worked with the Microsoft Visual C++ compiler support features for
COM, you may be familiar with the
#import
directive. While #import reverse-engineers type
information to generate wrapper classes for COM interfaces,
#using makes accessible all types from the
specified DLL, similar to a #include directive in
C or C++. However, unlike #include, which imports
C or C++ types, #using imports types for any .NET
assembly, written in any .NET language.
Console class. The L that
prefixes the literal string tells the C++ compiler to convert the
literal into a Unicode string. You may have already guessed that the
Console class is a type hosted by mscorlib.dll,
and it takes one string parameter.
using
namespace statement.
This allows us to refer to Console instead of having to fully qualify
this class as System::Console.
int i; // primitive
struct Point { int x, y; } // structure
enum State { Off, On } // enumeration
#using<mscorlib.dll>
using namespace System;
public _ _gc _ _interface ISteering
{
void TurnLeft( );
void TurnRight( );
};
public _ _gc class Vehicle : public ISteering
{
public:
virtual void TurnLeft( )
{
Console::WriteLine("Vehicle turns left.");
}
virtual void TurnRight( )
{
Console::WriteLine("Vehicle turn right.");
}
virtual void ApplyBrakes( ) = 0;
};xcopy
of your application files from the source installation directory to
the destination directory. When you want to remove the application,
remove these directories. You don't have to write code to store
information into the registry, so there's no worrying about
whether you've missed inserting a registry setting for correct
application execution. In addition, because nothing is stored in the
registry, you don't have to worry about registry residues.
in
or out attributes, as in the following example:
HRESULT SetAge([in] short age); HRESULT GetAge([out] short *age);
in attribute tells the marshaler to send the
contents from the client to the server, and the
out attribute tells the marshaler to send the
contents from the server to the client. In the SetAge( ) method,
passing age from the server to the client will
just waste bandwidth. Similarly, there's no need to pass
using System;
using System.Messaging;
public struct Customer
{
public string Last;
public string First;
}
public class Enqueue
{
public static void Main( )
{
try
{
string path = ".\\PRIVATE$\\NE_queue";
if(!MessageQueue.Exists(path))
{
// Create our private queue.