Using pseudocode or C + + code, and the following ADT set operations, write a fu
ID: 3775714 • Letter: U
Question
Using pseudocode or C + + code, and the following ADT set operations, write a function Setintersection(const CSet &S;, const CSet &T;, CSet &SnT;) to compute the intersection of 2 unordered sets. The intersection of 2 sets is a set made up of the elements that are common to both of the 2 sets. For example, if S = {-1, 8, 6, 7, 5, 3, 0, 9, -1} and T = {7, 7, -1, 7, 4, -1}, then the intersection of S and T, denoted S T, is S T = {-1, 7}. Note that although the element -1 occurs twice in each of S and T, it appears only once in the intersection of S and T. Lastly, note that you may not access the internal data members of the set ADT. class CSet: int GetNumltems() const//get the number of items in a set void Insert(const ItemType &x;)//insert an item x into a set void Remove (const ItemType &x;)//remove first occurence of an item x from a set bool Isltem(const ItemType &x;)//returns true if an item x is in a set, false otherwise void ResetItems()//sets an iterator to the first item in a set bool GetNextItem(ItemType &x;)//returns the next item x from a set; returns false if x is the last item, true otherwiseExplanation / Answer
===========================================================
--------------
Answer:
--------------
Given code
class CUserInput(){
public:
CUserInput();
void AcceptUserInputFromKeyboard();
string GetUserInput() const;
private:
string m_sUserInput;
};
In the above code only first statement in wrong syntax.
class CUserInput(){ // Line1
As per the C++ guidelines , Class can not have open and close () parenthesis.
The correct format of the code is: class CUserInput{ // Line1
Additionally as per best programming practices, A parameterized constructor should be present to initialize the m_sUserInput,
which makes more readable while creating object instead of setting it from AcceptUserInputFromKeyboard() function.
The parameterized constructor as syntax as follows:
CUserInput(string input) {
m_sUserInput = input;
}
===========================================================
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.