580_exam3_Fa2020_A ET580, Exam3, Fall 2020, Version A Submission detail: A) Submit cpp file for each question with given main function. B) points distribution: 50% compilation, 50% correctness. Q1:...

I need the code


580_exam3_Fa2020_A ET580, Exam3, Fall 2020, Version A Submission detail: A) Submit cpp file for each question with given main function. B) points distribution: 50% compilation, 50% correctness. Q1: Create a class named Object. (15pt) 1. Dynamic data member: value - use template for type value 2. One argument constructor 3. Output function - print value 4. Mutator and accessor function for value Use following main() to test your function. int main(){ Object a(10); a.output(); a.setValue(12); cout< b(1.5);="" b.output();=""> c("Hi"); c.output(); } Output from main: Value: 10 12 Value: 1.5 Value: Hi Answer: Q2: Continue of previous question (15pt) 1. Copy the previous program to a new file. 2. Implement big three for Object class. Use following main() to test your function. int main(){ Object a(10); a.output(); ET580, Exam3, Fall 2020, Version A Object b(a),c(2); b.output(); c = b; c.output(); } Output from main: Value: 10 ==>(Object) copy constructor was called. Value: 10 ==>(Object) assignment operator was called. Value: 10 ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. Q3: Continue of previous question (15pt) 1. Copy the previous program to a new file. 2. One argument constructor for NumberObj. 3. Create a class named NumberObj derived from Object. 4. Override output function - print as “Number: value”; Use following main() to test your function. int main(){ NumberObj a(12); a.output(); NumberObj b(12.12); b.output(); } Output from main: Number: 12 Number: 12.12 ==>(Object) destructor was called. ==>(Object) destructor was called. Q4: Continue of previous question (15pt) 1. Copy the previous program to a new file. 2. Overload the operator + to output NumberObj objects. 3. Overload the operator - to output NumberObj objects. ET580, Exam3, Fall 2020, Version A Use following main() to test your function. int main(){ NumberObj a(12),b(10); NumberObj c = a+b; c.output(); NumberObj d(1.5),e(0.3); NumberObj f = d-e; f.output(); } Output from main: Number: 22 Number: 1.2 ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. Q5: Continue of previous question (15pt) 1. Copy the previous program to a new file. 2. Overload the insertion operator < to="" output="" wholenumber="" objects.="" 3.="" overload="" the="" extraction="" operator="">> to input WholeNumber objects. Use following main() to test your function. int main(){ NumberObj a(12),b(10); cout<>a>>b; cout< d(1.5),e(0.3);=""><"enter two="" double:";="" cin="">>d>>e; cout(Object) destructor was called. 2 ==>(Object) destructor was called. Enter two integer:10 5 15 ==>(Object) destructor was called. 5 ==>(Object) destructor was called. 1.8 ==>(Object) destructor was called. 1.2 ==>(Object) destructor was called. Enter two double:1.7 0.4 2.1 ==>(Object) destructor was called. 1.3 ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. ==>(Object) destructor was called. Q6: Memoization (15pt) Bob’s sequence is given by Bn = Bn-1 + 2 * Bn-2 + Bn-3, B1 = 1 B2 =-2 B3 =3 a) Implement Bob’s sequence using recursion. Use following main to check your answer. int main(){ cout<><><><><><><><><><><><><><><> a(5); for(int i=0;i b; b.push_back("abc"); b.push_back("def"); b.push_back("ghl"); b.push_back("mnq"); print(b); // print abc def ghl mnq doubleIt(b); print(b); // print abcabc defdef ghlghl } Answer:
Dec 14, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here