Changes

Jump to: navigation, search

OOP344 Assignment Two

1,447 bytes added, 12:23, 19 October 2009
m
IO_Label
===IO_Label===
 
'''IO_Label''' class mostly, encapsulates the '''[[OOP344_Assignment_One#void_io_display.28const_char_.2Astr.2C_int_row.2C_int_col.2C_int_len.29|io_display()]]''' function.
Inherit a new class called IO_Label from IO_Field to Display a text message on IO_Form. In addition to the attributes of its parent IO_Field, IO_Label has a private integer attribute called _len. _len is used to hold the length of Field in which the text is to be displayed.
IO_Label could hold its data dynamically or simply point to an external one. Because of this IO_Label also has a boolean attribute called _dynamic that will hold the type of data within; being dynamic memory (value true), or external memory (value false)
'''IO_Label''' can be created in two ways:
 
<big><pre>
IO_Label(int row, int col, int len);
</pre></big>
 
This constructor will create an empty (blank) IO_Label with capacity of len characters.
In this case '''row''' and '''col''' are passed to the parent for initialisation and '''_len''' (the atterbute) is set to the incoming argument '''len''';
 
Then IO_Field::_data will be set to the address of a newly allocated memory to the size of '''_len + 1 ''' bytes which also will be set to an empty string.
 
''Note that '''data''' is a void pointer; to use it here, you must cast it to a character pointer!''
'''_dynamic''' attribute is set to true in this case.
 
<big><pre>
IO_Label(char* str, int row, int col, int len = 0);
</pre></big>
===IO_Edit===

Navigation menu