Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program6 Submit Assignment Due Friday by 11:59pm Points 10 Submitting a text ent

ID: 3915354 • Letter: P

Question

Program6 Submit Assignment Due Friday by 11:59pm Points 10 Submitting a text entry box or a file upload Available Jun 8 at 12am Jul 20 at 11:59pm about 1 month 27. Find the error (s) in the following code template /Line 1 class strange /Line 2 strange s1 /Line 3 strange s2 //Line 4 28. Consider the following declaration template class strange //Line 2 private type a type b; 1. Write a statement that declars sObj to be an object of type strange such that the private member 2. Write a statement that declares sObj that shows the declaration in the class strange to overload the 3. Assume that two objects of type strange are equal if their corresponding member variables are equal variables a and b are of type int. operatoras a member function. Write the definition of the function operatorfor the class strange, which is overloaded as member function

Explanation / Answer

27) missing semicolon (;) in line 3 and 4 //every c++ statement ends with a semicolon

};

strange <int> s1;

strange<int> s2;

//type there is replaced by valid datatype

28)

a)

private:

type a;

type b;

};

strange <int> sobj;

//sobj is the object <int> specifies that the variable inside sobj will be of int type

29)

1) 12

//as after calling function surprise and passing an integer to it type becomes int and hence returns a sum of 5+7=12

2) sunnyday

//string is sent so type is converted to string

30)

output 1: 376

output 2: mikemiller

// the logic behind the program is that the function funcExp iterates through the array to find lagest and smallest element in the array and returns their sum

31)

//following is the full source code for the problem

#include<iostream>

using namespace std;

template <class T>

void swap(T&x,T&y) //Function Template

{

T temp=x;

x=y;

y=temp;

}

int main()

{

int x1=5,y1=8;

float x2=4.2,y2=6.6;

cout<<“Before Swap:”;

cout<<“x1=”<<x1<<“y1=”<<y1<<endl;

cout<<“x2=”<<x2<<y2=”<<y2<<endl;

swap(x1,y1);

swap(x2,y2);

cout<<“After Swap:”;

cout<<“x1=”<<x1<<“y1=”<<y1;

cout<<“x2=”<<x2<<“y2=”<<y2;

return 0;

}