got this assignment to write a class for sets and provide various member functions e.g add code, set union. each set has a certain number of codes. each code is a 5 charater c-string. i cant seem to get the set union (below) working.
the codes from a (codes) and b (u.codes) dont seem to get stored in union_set.
set operator+( const set& u ) const; //this operator is the set_union() function
char (*codes)[string_length]; //variable codes is a pointer to an array of characters "5"
int num_codes; //the memory for the number of codes and the 5 character string
set set::operator+( const set& u ) const
int i, j = 0;
union_set.num_codes = num_codes + u.num_codes; // e.g num_codes = 2 and u.num_codes = 1, union_set.num_codes = 3
union_set.codes = new char[union_set.num_codes][string_length]; //allocate memory needed
for (i < 0; i < num_codes; i++)
for (j = 0; j < string_length; j++) //codes from a will go into union_set.codes e.g union_set.codes = codes
union_set.codes[i][j] = codes[i][j];
for (i = num_codes; i < union_set.num_codes; i++) //codes from a will go into union_set.codes e.g union_set.codes = u.codes
for (j = 0; j < string_length; j++)
union_set.codes[i][j] = u.codes[i-num_codes][j]; //u.codes[i-num_codes] means u.codes starts at 0
set a, b, un;
un = a + b;
anyhelp would be grateful as assignment is due in soon, thanks