L
Latina
Hi, I am doing a program of overloaded methods.
I want to get what is the union of the user set and S set and the user
set and S1 set.
I try it but it is not working.
Can some one help me please?
Here is part of my code:
class IntegerSet
{
private:
bool set[26];
int element;
public:
//Operator methods.
IntegerSet operator + (const IntegerSet &)const; //Method
union
};
void IntegerSet::setString()
{
cout<<"{";
for(element=0; element<26; element++)
{
if(set[element]==true)
{
cout<<" "<<element<<" ";
}
}
cout<<"}";
}
main()
{
for(int i=2; i<21; i++)
{
if(i%2==0)
S1set.insertElement(i);
}
for(int z=0; z<26; z++)
{
Sset.insertElement(z);
}
int temp, ele;
int newSet[26];
cout<<"Enter how many elements you want in the set: ";
cin>>ele;
cout<<"Enter the values: \n";
for(int i=0; i<ele; i++)
{
cout<<i+1<<": ";
cin>>temp;
newSet=temp;
}
IntegerSet S4set(newSet, ele);
cout<<"Your set is: ";
S4set.setString();
cout<<"\n\nSelect one of these choices:\n";
cout<<" 1. Find Union \n";
cout<<"Choice: ";
cin>>choice;
if(choice==1)
{
char a, b, option;
cout<<"\nYour set is: ";
S4set.setString();
cout<<"\nSet S: ";
Sset.setString();
cout<<"\nSet S1: ";
S1set.setString();
cout<<"\n\nSelect one of this choices to find the union of:\n";
cout<<" a. Your set and set 'S'\n";
cout<<" b. Your set and set 'S1'\n";
cout<<"Option: ";
cin>>option;
IntegerSet unio();
if(option=='a'||option=='A')
{
unio = S4set.operator+(Sset);
}
else if(option=='b'||option=='B')
{
unio = S4set.operator+(S1set);
}
cout<<"The union of the two sets is: \n";
unio.setString();
}
}
Thanks
I want to get what is the union of the user set and S set and the user
set and S1 set.
I try it but it is not working.
Can some one help me please?
Here is part of my code:
class IntegerSet
{
private:
bool set[26];
int element;
public:
//Operator methods.
IntegerSet operator + (const IntegerSet &)const; //Method
union
};
void IntegerSet::setString()
{
cout<<"{";
for(element=0; element<26; element++)
{
if(set[element]==true)
{
cout<<" "<<element<<" ";
}
}
cout<<"}";
}
main()
{
for(int i=2; i<21; i++)
{
if(i%2==0)
S1set.insertElement(i);
}
for(int z=0; z<26; z++)
{
Sset.insertElement(z);
}
int temp, ele;
int newSet[26];
cout<<"Enter how many elements you want in the set: ";
cin>>ele;
cout<<"Enter the values: \n";
for(int i=0; i<ele; i++)
{
cout<<i+1<<": ";
cin>>temp;
newSet=temp;
}
IntegerSet S4set(newSet, ele);
cout<<"Your set is: ";
S4set.setString();
cout<<"\n\nSelect one of these choices:\n";
cout<<" 1. Find Union \n";
cout<<"Choice: ";
cin>>choice;
if(choice==1)
{
char a, b, option;
cout<<"\nYour set is: ";
S4set.setString();
cout<<"\nSet S: ";
Sset.setString();
cout<<"\nSet S1: ";
S1set.setString();
cout<<"\n\nSelect one of this choices to find the union of:\n";
cout<<" a. Your set and set 'S'\n";
cout<<" b. Your set and set 'S1'\n";
cout<<"Option: ";
cin>>option;
IntegerSet unio();
if(option=='a'||option=='A')
{
unio = S4set.operator+(Sset);
}
else if(option=='b'||option=='B')
{
unio = S4set.operator+(S1set);
}
cout<<"The union of the two sets is: \n";
unio.setString();
}
}
Thanks