Teorija CPP: cestnoprometni predpisi: C, E, D – kat.: (za interno uporabo). Front Cover. Bojan Krajnc. B. Krajnc, – 89 pages. Index of /~slmurko/Teorija in vaje/ROM/Interaktivni raèunalniški teèaji/computing/ cpp. [ICO], Name · Last modified · Size · Description. [DIR], Parent Directory, -. Parent Directory, -. [TXT], BARCHART.C, Feb , K. [TXT], , Feb , K. [ ], , Feb , K.
|Published (Last):||8 September 2006|
|PDF File Size:||7.94 Mb|
|ePub File Size:||10.44 Mb|
|Price:||Free* [*Free Regsitration Required]|
This chapter is a short survey of programming techniques. We use a simple example to illustrate the particular properties and to teogija out their main ideas and problems. Roughly speaking, we can distinguish the following learning curve of someone who learns program:. This chapter is organized as follows.
Usually, people start learning programming by writing small and simple programs consisting only of one main program. We can illustrate this as shown in Fig. The main program directly operates on global data. As you should all know, this programming techniques provide tremendous disadvantages once the program gets sufficiently large.
For example, if the same statement sequence is needed at different locations heorija the program, the sequence must be copied. This has lead to the idea to extract these sequencesname them and offering a technique to call and return from these procedures. Yeorija procedural programming you are able to combine returning sequences of statements into cp single place.
A procedure call is used to invoke the procedure. After the sequence is processed, flow of control proceeds right after the position where the call was made Fig. After processing flow of controls proceed where the call was made. With introducing parameters as well as procedures of procedures subprocedures programs can now be written more structured and error free.
For example, if a procedure is correct, every time it is used it produces correct results. Consequently, in cases of errors you can narrow your search to those places which are not proven to be correct. Now a program can be viewed as a sequence of procedure calls.
The main program is responsible to pass data to the individual calls, the data is processed by the procedures and, once the program has finished, the resulting data is presented. Thus, the flow of data can be illustrated as a hierarchical graph, a treeas shown in Fig. The main program coordinates calls to procedures and hands over appropriate data as parameters.
Now we have a single program which is divided into small pieces called procedures. To enable usage of general procedures or groups of procedures also in other programs, they must be separately available.
Formats and Editions of Teorija CPP : cestnoprometni predpisi : (za interno uporabo) 
For that reason, modular programming allows grouping of procedures into modules. With modular programming procedures of a common functionality are grouped together into separate modules. A program therefore no longer consists of only one single part. It is now divided into several smaller parts which interact through procedure calls and which form the whole program Fig. The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters.
Each module can have its own data. This allows each module to manage an internal state which is modified by calls to procedures of this module. However, there is only one state per module and each module exists at most once in the whole program. Programs use data structures to store data. Several data structures exist, for example lists, trees, arrays, sets, bags or queues to name a few.
Each of these data structures can be characterized by their structure and their access methods. You all know singly linked lists which use a very simple structure, consisting of elements which are strung together, as shown in Fig. Structure of a singly linked list.
Singly linked lists just provides access methods to append a new element to their end and to delete the element at the front. Complex data structures might use already existing ones. For example a queue can be structured like a singly linked list. However, queues provide access methods to put a data element at the end and to get the first data element first-in first-out FIFO behaviour.
We will now present an example which we use to present some design concepts. Since this example is just used to illustrate these concepts and problems it is neither complete nor optimal.
Suppose you want to program a list in a modular programming language such as C or Modula As you believe that lists are a common data structure, you decide to implement it in a separate module.
Typically, this requires to write two files: Within this chapter we will use a very simple pseudo code which you should understand immediately. Our interface definition might then look similar to that below:.
Interface definitions just describe what is available and not how it is made available. You hide the information of the implementation in the implementation file. This is a fundamental principle in software engineering, so let’s repeat it: You hide information of the actual implementation information hiding.
Index of /~slmurko/Teorija in vaje/LAV/Software_145/KRMILJA/TC/EXAMPLES
This enables you to change the implementationfor example to use a faster but more memory consuming algorithm for storing elements without the need to change other modules of your program: The calls to provided procedures remain the same. The idea of this interface is as follows: The following two procedures implement the mentioned access methods fpp and delete.
The append procedure needs a more detailed discussion. This is necessary since you wish to use your list in several different environments, hence, the type of the data elements to be stored in the list is not known beforehand. Consequently, you have to use a special type ANY which allows to assign data of any type to it.
For teoriua you might want to release allocated memory. Traversing can be done using the following teoria. Now you have a list module which allows you to use a list with any type of data elements. But what, if you need more than one list in one of your programs? You decide to redesign your list module to be able to manage more than one list.
You therefore create a new interface description which now includes a definition for a list handle. This handle is used ccpp every provided procedure to uniquely identify the list in question. Your interface definition file of your new list module looks like this:.
We do not specify, how this handle is actually represented or even implemented. You also hide the implementation details of this type in your implementation file. Note the difference to the previous version where you just hide functions or procedures, respectively. Every other procedure now contains the special parameter cppp which just identifies the list in question.
All procedures now operate on this handle rather than a teorja global list.
Index of /~murkos/Teorija in vaje/LAV/Software_/KRMILJA/TC/BIN
Now you might say, that you can create list objects. Each such object can be uniquely identified by its handle and only those methods are applicable which are defined to operate on this handle. The previous section shows, that you already program with some object-oriented concepts in mind.
However, the example implies some problems which we will outline now. If you want to use a list within a procedure, say, foo you use the following code frame:. Let’s compare the list with other data types, for example an integer. Integers are declared within a particular scope for example within a procedure. Once you’ve defined them, you can use them.
Once you leave the scope for example the procedure where the integer was defined the integer is lost. It is automatically created and destroyed. Some compilers even initialize newly created integers to a specific value, typically 0 zero. The lifetime of a list is also defined by its scope, hence, it must be created once the scope is entered and destroyed once it is left. On creation time a list should be initialized to be empty. Therefore we would like to be able to define a list similar to the definition of an integer.
A code frame for this would look like this:.
The advantage is, that now the compiler takes care of calling initialization and termination procedures as appropriate. For example, this ensures that the list is correctly deleted, returning resources to the program. Decoupling of data and operations leads usually to a structure based on the operations rather than the data: You then use these operations by providing explicitly the data to them on which they should operate.
The resulting module structure is therefore oriented telrija the operations rather than the actual data. One could say that the defined operations specify the data to be used.
In object-orientation, structure is organized by the data. You choose the data representations which best fit your requirements.
Consequently, your programs get structured by the data rather than operations.
Thus, it is exactly the other way around: Data specifies valid operations. Now modules group teorij representations together. In our list example we have to use the special type ANY to allow the list to carry any data we like.