User: alciro    User
 Original    Translate to:  Deutsch  English  Français  中文  
 

Programación en C++ Builder

 Arrays (arrays)
 Pointers
3. Example of class in c + +
8. AnsiString class methods
 C + + projects
 Packages, distribute an application without installation
 Exchange or bubble sorting
 String string.h functions

C + + projects

    A project in c + + Builder consists of a set of files among them the following, with the extensions:

    • . Cpp source file C + +. File is available for the project (Proyect1.cpp). One per unit (Unit1.cpp).
    • . Dfm contains the description of the form and components that comprise it. Each form has its file description.
    • . Dsk state and appearance of your desktop when you save the project.
    • . H header files containing the declarations of the classes.
    • . Bpr project makefile. Contains information about files and compiler directives that need to build the program.
    • . Obj files generated by the compiler after treating the source files.
    • . Res binary resource file.
    • . Tds Archive of debugger symbols.

    To examine the files that are part of our project was to access the Builder Project Manager located in the menu View -> Project Manager.

    Projet Manager C + + Builder

    Unit1.cpp program source file

     //------------------------------------------------ ---------------------------
    
    # Include 
    # Pragma hdrstop
    
    # Include "Unit1.h"
    //------------------------------------------------ ---------------------------
    # Pragma package (smart_init)
    # Pragma resource "*. dfm"
    TForm1 * Form1;
    //------------------------------------------------ ---------------------------
    __fastcall TForm1:: TForm1 (TComponent * Owner)
            : TForm (Owner)
    {
    }
    //------------------------------------------------ ---------------------------
    
    void __fastcall TForm1:: Button1Click (TObject * Sender)
    {
    Edit1-> Text = "Hello";
    }
    //------------------------------------------------ ---------------------------
    

    Unit1.h header file

     //------------------------------------------------ ---------------------------
    
    # Ifndef Unit1H
    # Define Unit1H
    //------------------------------------------------ ---------------------------
    # Include 
    # Include 
    # Include 
    # Include 
    //------------------------------------------------ ---------------------------
    class TForm1: public TForm
    {
    __published: / / IDE-managed Components
            TButton * Button1;
    	TEdit * Edit1;
            void __fastcall Button1Click (TObject * Sender);
    private: / / User declarations
    public: / / User declarations
            __fastcall TForm1 (TComponent * Owner);
    };
    //------------------------------------------------ ---------------------------
    extern PACKAGE TForm1 * Form1;
    //------------------------------------------------ ---------------------------
    # Endif
    

    Project1.cpp project source file

     //------------------------------------------------ ---------------------------
    
    # Include 
    # Pragma hdrstop
    //------------------------------------------------ ---------------------------
    USEFORM (Unit1.cpp ", Form1);
    //------------------------------------------------ ---------------------------
    WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int)
    {
            try
            {
                     Application-> Initialize ();
                     Application-> CreateForm (__classid (TForm1), & Form1);
                     Application-> Run ();
            }
            catch (Exception & exception)
            {
                     Application-> ShowException (& exception);
            }
            catch (...)
            {
                     try
                     {
                             throw Exception ("");
                     }
                     catch (Exception & exception)
                     {
                             Application-> ShowException (& exception);
                     }
            }
            return 0;
    }
    //------------------------------------------------ --------------------------- 

    Loading
    copyright © 2007-2014  www.alciro.org  All rights reserved.         
    Share |