Question: Template Specialization You are given a Div class template, which has a constructor that takes two parameters and outputs their division. You need to specialize

Template Specialization

You are given a Div class template, which has a constructor that takes two parameters and outputs their division. You need to specialize the class for strings, which should output the division of the lengths of the parameter strings, as the division operator is not defined for strings. Create the template specialization so that the code in main executes correctly.

You can get the length of a string using the size() function.

#include

using namespace std;

template

class Div {

public:

Div (T x, T y) {

cout <

}

};

//your code goes here

int main () {

string a, b;

cin >> a >> b;

int x, y;

cin >> x >> y;

Div d2(a, b);

Div d1(x, y);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!