Monday, 6 July 2015

Chapter 4


Defining C++ Classes

  • Defining a class
  • Creating a class instance
  • Accessing class members
  • Encapsulation
  • Constructors and destructors
  • Inline member functions
  • The this pointer
  • Static class members
           This Chapter introduces C++ Classes. When you define a class, you create a new data type, which you can use much like on of the built - in C++ data types. A class, however, contains code as well as data. A class allows you to encapsulate all a window on the screen, a figure that the program draws, a device connected to a techniques for creating and using individual classes. In the next chapter, you'll learn how to define and use hierachies of related classes.


  • Defining a Class
          A C++ class is somewhat similar to a standard C structure, though the features of C++ classes go far beyond those provided by C structures. To understand C++ classes, it's useful to start by considering how structure are used in the C language.

         A C structure allows you to group a set of related data items. As a simple example, if your C program draws a rectangle on the screen, you might find it convenient to store the coodinates of the rectangle within a structure  defined as follows : 

         Struct Rectangle 
        {
            int   Left;
            int   Top;
            int   Right;
            int   Bottom;
          };
              You could then define a function for drawing the rectangle, as in the following example.
             Void Draw Rectangle (Struct Rectangle *Rect)

Chapter 3


Moving to C + +

  • Converting from C to C++
  • New features of C++

  • Converting from C to C++
        If you've written a C program, you've probably already written your first C++ program ! With few excpection, C++ is a superset of C; that is, C++ supports almost all the features of the C language in addition to the many new features that it offers. Therefore, to get started with C++, you can simply compile your existing C programs, as well as the new programs you write, using the C++ compiler rather than the C compiler. You can then gradually begin adding to your code various features that are unique to C++


        To begin using the C++ compiler, you need only name your source file with the .cpp or .cxx extension, rather than the .c extension. There are, however several programming practices permitted in most versions of C that won't compile using the C++ compiler, or that will compile with C++ but with altered meanings. The following is a description of some of the most important C constructs that don't work with C++:


  • C++ has many more reserved keywords than C; these are words that you can't use as identifies in your programs. The following is a list of the reserved key - words used in Visual C++. This list includes the C Keywords, Plus many additional ones unique to  C++:
     auto               else                new              this
     bad-cast           enum                operator         throw
     bad_typeid         except              private          true
     bool               explicit            protected        try
     break              extern              public           type_info
     case               false               register         typedef
     catch              finally             reinterpret_     typeid

Chapter 2


Creating a Program Using the Microsoft Developer Studio
  • Creating the project
  • Creating and editing the program source file
  • Changing project settings
  • Building the program
  • Running the program
  • Debugging the program


  • Creating the Project : 
          To run the Developer Studio, choose the Microsoft Visual C++6 command on the Programs submenu of your Windows Start menu, which will look something like this.

          Once the Developer Studio beguns running, the first step is to create a project for the program you're about to write. A visual C++ project stores all the information required to build a particular program. This information required to build a particular program. This information includes the names and relationships of the program source files; a list of the required library files; and a list relationships of the progrram source files; a list of the required library files; and a list of all options for the compiler linker, and other tools used in building the program.



           1.       Choose the File > New  . . . menu command in the Developer Studio, or simply press Ctrl+N.                      The New dialog box will appear.   

           2.       Open the projects tab of the New dialog box (if it's not already open), So that you can create                        a new project.

Chapter 1

SETTING UP THE SOFTWARE

  • Installing Microsoft Visual C++ 6
  • What's included in Visual C++ 6 
  • Using the Companion CD

         This Chapter describes how to install Microsoft Visual C++ 6 and provides an overview of the Visual C++ Components to help you choose the appropriate installation options and to introduce you to the product. The chapter concludes with instructions for using the companion CD provided with this book.

  • Installing Microsoft Visual C++
         To use visual C++ 6, you must be running Windows 95 or a later version, or Windows NT version 4.0 or later (see the visual C++6 documentation for additional requirements). To install Visual C++ on your hard disk, insert the product CD into you CD-ROM drive (if there are several CDs, insert the first one). If the CD Autorun feature is enabled on your computer, the Setup program will automatically begin running after a few seconds. If this doesn't happen, run the Setup.exe program in the root folder of the CD. Then simply enter the requested information, and setup will install Visual C++6 on your Hard disk.
______________________________________________________________________________
Note:         Through this book, Windows 95 refers to Windows 95 or a later version, windows NT refers to Windows NT                          version 4.0 or later, and Windows refers to either system.
_____________________________________________________________________________________________
    
        The Particular Setup Options and components that you see depend on whether you have the Visual Studio 6 product (Which includes Visual Basic 6, Visual C++ 6, Visual J++6, and other development environments) or you have just Visual C++ 6. The available options and components also depend on which version of visual Studio 6 or visual C++6 you have Standard, Professional , or Enterprise.

           The Setup program will give you the opportunity to customize your installation by choosing individual components from a series of dialog boxes. For example, If you're installing the Visual Studio 6.0 Enterprise Edition, the Setup program displays the "Visual Studio 6.0 Enterprise Custom" Dialog box shown in figure 1.1 The components listed in this dialog box include all the major development environments provided with Visual Studio 6.0 (Microsoft Visual Basic 6.0, Microsoft Visual C++ 6.0, and so on), plus the following common tools and accessories that you can use with one or more of the development environments:

  • Active X
  • Data Access
  • Enterprise Tools
  • Graphics
  • Tools
              Check the box next to each component that you want to include in your installation, and clear the check mark from each component you want to exclude. Click the Select All button if you want to include all the components. 



              Each of the main Visual Studio components shown figure 1.1 consists of  a collection of subcomponents, which you can choose individually (except ,sit. ActiveX, which has no subcomponents). A check mark in a dimmed box ipth-cates that the component will be installed but not all its subcomponents. To specify which subcomponents are installed if a component is checked, highlight the component by clicking on it, click the Change Option... button, and then select the subcomponents you want in the dialog box that appears. For example, if you highlight Microsoft Visual C++ 6.0 and click Change Option..., the Visual Studio Setup program will display the dialog box shown in Figure 1.2. This dialog box lists the installable subcomponents that are specific to Visual C++

Thursday, 25 June 2015

CONTENTS AT A GLANCE

                  Introduction

Part I :      Introduction to Microsoft Visual C++ 6

                       Chapter # 1 : Setting Up the Software
                       Chapter # 2 : Creating a Program Using the Microsoft Developer Studio

Part II :     Introduction to C++

                       Chapter # 3 : Moving to C++
                       Chapter # 4 : Defining C++ Classes
                       Chapter # 5 : Deriving C++ Classes
                       Chapter # 6 : Overlanding , Copying and Converting
                       Chapter # 7 : Using C++ Templates
                       Chapter # 8 : Handling Exceptions in C++

Part III :   Windows GUI programming with the MFC Library

                       Chapter # 9   : Generating a Windows GUI Program
                       Chapter # 10 : Implementing the View
                       Chapter # 11 : Implementing the Document
                       Chapter # 12 : Storing Documents in Disk Files
                       Chapter # 13 : Scrolling and Splitting Views
                       Chapter # 14 : Including Docking Toolbars and Status Bars
                       Chapter # 15 : Creating Custom Dialog Boxes
                       Chapter # 16 : Writing Dialog Based Applications
                       Chapter # 17 : Writing Multiple Document Applications
                       Chapter # 18 : Performing Character I/O
                       Chapter # 19 : Using Drawing Functions
                       Chapter # 20 : Using Bitmaps and Bit Operations
                       Chapter # 21 : Printing and Print Previewing
                       Chapter # 22 : Using Mutliple Threads
                       Chapter # 23 : Communicating Among Processes
                       Chapter # 24 : Using OLE
                       Chapter # 25 : Creating and Using Active X Controls

                  Introduction

Part I :      Introduction to Microsoft Visual C++ 6

                       Chapter # 1 : Setting Up the Software
                       Chapter # 2 : Creating a Program Using the Microsoft Developer Studio

Part II :     Introduction to C++

                       Chapter # 3 : Moving to C++
                       Chapter # 4 : Defining C++ Classes
                       Chapter # 5 : Deriving C++ Classes
                       Chapter # 6 : Overlanding , Copying and Converting
                       Chapter # 7 : Using C++ Templates
                       Chapter # 8 : Handling Exceptions in C++

Part III :   Windows GUI programming with the MFC Library

                       Chapter # 9   : Generating a Windows GUI Program
                       Chapter # 10 : Implementing the View
                       Chapter # 11 : Implementing the Document
                       Chapter # 12 : Storing Documents in Disk Files
                       Chapter # 13 : Scrolling and Splitting Views
                       Chapter # 14 : Including Docking Toolbars and Status Bars
                       Chapter # 15 : Creating Custom Dialog Boxes
                       Chapter # 16 : Writing Dialog Based Applications
                       Chapter # 17 : Writing Multiple Document Applications
                       Chapter # 18 : Performing Character I/O
                       Chapter # 19 : Using Drawing Functions
                       Chapter # 20 : Using Bitmaps and Bit Operations
                       Chapter # 21 : Printing and Print Previewing
                       Chapter # 22 : Using Mutliple Threads
                       Chapter # 23 : Communicating Among Processes
                       Chapter # 24 : Using OLE
                       Chapter # 25 : Creating and Using Active X Controls