Difference between revisions of "Ide/Creating new Project Items/Creating a Class"

From wiki.visual-prolog.com
m (header level)
Line 1: Line 1:
<noinclude>[[Category:Ide]]</noinclude>
<noinclude>[[Category:Ide Create New Project Items]]</noinclude>
'''How to Create a New Class?'''
 
== Creating a Class ==
 


The declaration of a class defines how the class appears to the surroundings. The surroundings can see and use only those constants, domains, and predicates that are declared in the class declaration. If the class states an interface as the construction type, then the class can construct objects of that type. Everything mentioned in the class declaration belongs to the class, rather than to objects it constructs. Any class declaration must have the accompanying class implementation. The definitions of the predicates declared in the class declaration should be provided by the class implementation.
The declaration of a class defines how the class appears to the surroundings. The surroundings can see and use only those constants, domains, and predicates that are declared in the class declaration. If the class states an interface as the construction type, then the class can construct objects of that type. Everything mentioned in the class declaration belongs to the class, rather than to objects it constructs. Any class declaration must have the accompanying class implementation. The definitions of the predicates declared in the class declaration should be provided by the class implementation.

Revision as of 15:13, 13 June 2013


Creating a Class

The declaration of a class defines how the class appears to the surroundings. The surroundings can see and use only those constants, domains, and predicates that are declared in the class declaration. If the class states an interface as the construction type, then the class can construct objects of that type. Everything mentioned in the class declaration belongs to the class, rather than to objects it constructs. Any class declaration must have the accompanying class implementation. The definitions of the predicates declared in the class declaration should be provided by the class implementation.

To create a new class and to add it into one of packages registered in the project you should activates the File | New IDE command. Then in the left pane of the opened Create Project Item dialog you should select Class. Then the dialog accepts the following shape:

The New Class Dialog

Name:

In the Name edit control you should type in a class name (the newClassName on the picture).

Package:

In the Package list button you should select one of the packages registered in the project (the NewPackage.pack on the picture). The created class will be included into this package. The created files of this class will be placed into the selected package subdirectory. This subdirectory name is displayed after the package name; it is (NewPackage\) in the picture.

In namespace

The In namespace check box controls whether the class will be put into the namespace (e.g. namespace1\newClassName). This allows the same interface/class name to be declared/defined in several name spaces in the same program.

After you fill in all required settings for the class, you can press the Create button. Then the IDE creates the class declaration and the class implementation (if New Interface was checked ON) files. These files will appear in the project tree in the Project Window after compilation of the package) and the #include @"NewPackage\newClassName.cl" directive will be added into the correspondent package header or the package implementation file.

Notice that information about a new class does not appear in the project browse information until the class is compiled. To compile a new class, you can, for example, execute the Compile command for the package containing this class.