To add a class to your project, you have various options. You can separately create a header file then create a source file. You can also import an existing header file and a source file from any valid path. Microsoft Visual C++ makes it easy to create a C++ class. When doing this, a header and a source files are prepared. A (default) constructor and a destructor are added. You can delete or completely change the supplied constructor and/or the destructor. Also, Microsoft Visual C++ includes the name of the header file in the source file so you would not have forgotten to do this. Most classes in Microsoft Visual C++ have their names starting with the letter C. Although this is only a suggestion, and any valid class name would work fine, to keep some harmony, in our lessons, we will follow this convention.
To create a new class and add it to your project:
- On the main menu, click Insert -> Add Class...
- In the Class View, right-click the name of the project, position the mouse on Add, and click Class...
Any of these actions would open the New Class dialog box. From there, you can specify the type of class you want to create and click Open. You will then be asked to provide a name for the class.
Comments
Post a Comment