Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I did number one but i need #2 and #3 -class name is Pairsummable -language :C++ Specializations 1) for K = std::string and V

Hi, I did number one but i need #2 and #3
-class name is Pairsummable
-language :C++
Specializations
1) for K = std::string and V = std::string, the initial value for summation should be set to empty string ("").
2) for K = std::string and V = int, the initial value for summation should be set to 0.
3) for K = std::string and V = std::string, the function sum() should concatenate the values stored using , as separator (use operator + to concatenate strings).
Answer for (1)
template
std::string PairSummable<:string std::string>::initial = std::string("");
I just need template specilization, i did number 1 and answered it (see below)
here is the sum function, i tried doing the apecialization, is it correct? image text in transcribed
image text in transcribed
public: static const V& getInitialValue() { return m_initialval; PairSummable() { PairSummable(const K& key, const V& value) : Pair (key, value) { (m_minfield :: key getkey()) { return key getkey) + val; else { return val; void display (std::ostream& os) const os.setf(std::ios::left); os.width(m_minField); os ::getKey() ::getValue() std::strine PairSummable<:string std::string>::n_initialval - std::string(); template std::string PairSummable<:string int>::m_initialval.; template> size_t PairSummable<:string size_t>::sum(const & key, const V& val)const= key +","+ val

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

Explain two important characteristics of professional skepticism.

Answered: 1 week ago