Start Microsoft Visual Studio .NET, select New from the File menu, and then select Project. The New Project dialog box appears.
Set the Project Type to Visual C++ Projects, and set the Template to Console Application (.NET). Type Variables in the Name text box, and choose a location for your new project. Click OK.
From the Project menu, select Add Class. The Add Class dialog box appears.
Set the Template to Generic C++ Class. Click Open. The Generic C++ Class Wizard dialog box appears.
Type Animal in the Class name text box. Notice how default names for the header and source files are created automatically.
Leave the Base class text box blank.
In the Access list, select public. (Note that public is the default, so it should already be selected.)
Check the Virtual destructor check box.
Note that the header file for the new class, Animal.h, has been loaded into the main window. In Solution Explorer, the Animal.cpp file has been added to the Source Files folder and the header file, Animal.h, has been added to the Header Files folder. In the Class View window, if you expand the Variables project node, you’ll see that the new Animal class has been added to the project. If you expand the Animal class, you’ll see the default constructor, Animal(void), and destructor, ~Animal(void), for the class.
In the Class View window, expand the Variables node, right-click the Animal class, select Add, and then select Add Variable. Accept the default access modifier, public.
Select int from the Variable type drop-down menu.
Type legs in the Variable name text box.
In this exercise, you’ve seen how to create a new class using Visual Studio and how to add members to it.