I am to create a program with a Class Set having the the following member functions:

Set()

void AddElement(int v)

void RemoveElement(int v)

void Print()

then write the following friend functions of class Set:

void Union(Set A, Set B), which calculates and prints the union of A and B

void Intersect(Set A, Set B), which calculates and prints the intersection of A and B

void Minus(Set A, Set B), which calculates and prints the minus of A and B

Write the following function to overload the following operations:

= (Creates a new set from old set. For instance, A=B creates A from B)

+ (Creates union of two sets. For instance, C=A+B creates union of A and B into C)

* (Creates intersection of two sets. For instance, C=A*B creates intersection of A and B into C)

- (Creates minus of two sets. For instance, C=A-B creates minus of A and B into C)

Write a program which will take the elements of first set until user enters -1. Similarly, the program will take the elements of second set until user enters -1. Then show the following outputs in the console:

a. Elements of first set using Print() function of class

b. Elements of second set using Print() function of class

c. Union of the sets using friend function

d. Union of the sets using operator overloading (+)

e. Intersection of the sets using friend function

f. Intersection of the sets using operator overloading (*)

g. Minus of the sets using friend function

h. Minus of the sets using operator overloading (-)

Sample input:

1 3 5 6 8 10 12 -1

2 4 5 6 7 11 13 -1

Sample output:

First set: 1 3 5 6 8 10 12

Second set: 2 4 5 6 7 11 13

Union (friend): 1 2 3 4 5 6 7 8 10 11 12 13

Union (operator overloading): 1 2 3 4 5 6 7 8 10 11 12 13

Intersection (friend): 5 6

Intersection (operator overloading): 5 6

Minus (friend): 1 3 8 10 12

Minus (operator overloading): 1 3 8 10 12

I am trying to create the first friend function and i am stuck. I am a new to programming language and i need help. Any help that can be provided is greatly appreciated. This is what i have so far, its not much, but as i said, i am stuck.

Set()

void AddElement(int v)

void RemoveElement(int v)

void Print()

then write the following friend functions of class Set:

void Union(Set A, Set B), which calculates and prints the union of A and B

void Intersect(Set A, Set B), which calculates and prints the intersection of A and B

void Minus(Set A, Set B), which calculates and prints the minus of A and B

Write the following function to overload the following operations:

= (Creates a new set from old set. For instance, A=B creates A from B)

+ (Creates union of two sets. For instance, C=A+B creates union of A and B into C)

* (Creates intersection of two sets. For instance, C=A*B creates intersection of A and B into C)

- (Creates minus of two sets. For instance, C=A-B creates minus of A and B into C)

Write a program which will take the elements of first set until user enters -1. Similarly, the program will take the elements of second set until user enters -1. Then show the following outputs in the console:

a. Elements of first set using Print() function of class

b. Elements of second set using Print() function of class

c. Union of the sets using friend function

d. Union of the sets using operator overloading (+)

e. Intersection of the sets using friend function

f. Intersection of the sets using operator overloading (*)

g. Minus of the sets using friend function

h. Minus of the sets using operator overloading (-)

Sample input:

1 3 5 6 8 10 12 -1

2 4 5 6 7 11 13 -1

Sample output:

First set: 1 3 5 6 8 10 12

Second set: 2 4 5 6 7 11 13

Union (friend): 1 2 3 4 5 6 7 8 10 11 12 13

Union (operator overloading): 1 2 3 4 5 6 7 8 10 11 12 13

Intersection (friend): 5 6

Intersection (operator overloading): 5 6

Minus (friend): 1 3 8 10 12

Minus (operator overloading): 1 3 8 10 12

I am trying to create the first friend function and i am stuck. I am a new to programming language and i need help. Any help that can be provided is greatly appreciated. This is what i have so far, its not much, but as i said, i am stuck.

PHP Code:

```
``````
#include <iostream>
```

using namespace std;

int inputArraySetA[20];

int inputArraySetB[20];

//int inputArrayUnion[20];

int sizeSetA = 0;

int sizeSetB = 0;

//int sizeUnion = 0;

int temp = 0;

class Set

{

protected:

int x;

int y;

public:

Set();

Set(int px,int py);

void AddElement(int v);

void RemoveElement(int v);

void Print();

friend void Union(int inputArraySetA[20], int inputArraySetB[20]);

friend void Intersect(int inputArraySetA[20], int inputArraySetB[20]);

friend void Minus(int inputArraySetA[20], int inputArraySetB[20]);

};

//--------------------------------------------------------------------------------------------------------------------

void Union(int inputArraySetA[20], int inputArraySetB[20])

{

}

//--------------------------------------------------------------------------------------------------------------------

int main()

{

cout << "Enter First set of numbers, (-1) to quit: "<<endl; // Takes the input of the first set of numbers

for (int i = 0; i < 20; i++)

{

cin >> temp;

if (temp == -1)

{

break;

}

else

{

inputArraySetA[i] = temp;

sizeSetA++;

}

}

cout << "Enter Second set of numbers, (-1) to quit: "<<endl; // Takes the input of the second set of numbers

for (int i = 0; i < 20; i++)

{

cin >> temp;

if (temp == -1)

{

break;

}

else

{

inputArraySetB[i] = temp;

sizeSetB++;

}

}

//--------------------------------------------------------------------------------------------------------------------

cout << "Set A is ";

for (int i = 0; i < sizeSetA; i++)

{

cout << inputArraySetA[i] << " ";

}

cout << "\nSet B is ";

for (int i = 0; i < sizeSetB; i++)

{

cout << inputArraySetB[i] << " ";

}

return 0;

}