Changes

Jump to: navigation, search

OOP344 Assignment Two

No change in size, 17:23, 4 November 2009
m
IO_Label
</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 initialization and '''_len''' (the attribute) 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!''<br />
IO_Label(char* str, int row, int col, int len = -1);
</pre></big>
If '''len''' is greater than zero, This constructor will create an IO_Label by allocating len + 1 characters pointed by IO_Field::_data, and then the contents of '''str''' is copied into IO_FiedlIO_Field::_data up to '''len''' characters. '''_len''' attribute is set to '''len''';
If '''len''' is less than or equal to zero, then '''len''' will be set to the length of '''str''' and then constructor will work as previous case.
Like the previous constructor it will pass '''row''' and '''col''' to its parent.

Navigation menu