(Solved) : Part 1 Conversion Constructors Write Conversion Constructors Queryresponse Serviceresponse Q44079375 . . .
C++ programming
Please follow the provided template,thanks

template
![int main(int argc, const char *argv[]) { // Part: 1 QueryResponse queryResponse (5); ServiceResponse serviceResponse (9); Que](https://media.cheggcdn.com/media/7e8/7e8846c4-55dd-434f-9475-67a831831e7a/phpN9jOUt.png)


Part 1 – Conversion Constructors Write Conversion Constructors for both QueryResponse and ServiceResponse in Response.cpp . Verify the following things in main class – 1. Create an object of QueryResponse and use the conversion constructor to create an object ServiceResponse from it. 2. Create an object of ServiceResponse and use the conversion constructor to create an object QueryResponse from it. Part 2 – Conversion Operators We can also use Conversion Operators instead of Conversion Constructors to achieve the same goal. Write Conversion Operators for both QueryResponse and ServiceResponse in Response.cpp . Verify the following things in main class – 1. Create an object of QueryResponse and use the conversion operator to create an object ServiceResponse from it. 2. Create an object of ServiceResponse and use the conversion operator to create an object QueryResponse from it. Part 3 – Friend Functions and Classes In order to get the ResponsePrinter class working, ResponsePrinter needs access to the private method getResponse of both QueryResponse & ServiceResponse classes. 1. Make ResponsePrinter a friend of QueryResponse to get the printQueryResponse method working. 2. Use the concept of Friend Function to get the printserviceResponse working. 3. Verify that you are able to print both in your main class. int main(int argc, const char *argv[]) { // Part: 1 QueryResponse queryResponse (5); ServiceResponse serviceResponse (9); QueryResponse convertedQueryResponse; ServiceResponse convertedServiceResponse; // Add Your Code here std::cout << “It should output 5: ” « std::cout << “It should output 9:” « convertedServiceResponse.getLength() < std::endl; convertedQueryResponse.getSize() < std::endl; // Part: 2 QueryResponse queryResponse (5); ServiceResponse serviceResponse (9); QueryResponse convertedQueryResponse; ServiceResponse convertedServiceResponse; // Add Your Code here std::cout << “It should output 5: ” << convertedServiceResponse.getLength() << std::endl; std::cout << “It should output 9:” << convertedQueryResponse.getSize() << std::endl; // Part 3 QueryResponse queryResponse (5); ServiceResponse serviceResponse (9); ResponsePrinter responsePrinter = ResponsePrinter(); // The following code should print the response responsePrinter.printServerResponse (serviceResponse); responsePrinter.printQueryResponse (queryResponse); Evoid ResponsePrinter::printServerResponse (ServiceResponse response) { std::cout « response.getResponse () « std::endl; Avoid ResponsePrinter::printQueryResponse (QueryResponse response) { std::cout << response.getResponse () < std::endl; L} // ServiceResponse ServiceResponse:: ServiceResponse (int length) : length (length) { } Dint ServiceResponse::getLength() { return length; Estd::string ServiceResponse::getResponse () { return “{‘length’: ” + std::to_string (length) + “}”; // Add your code for ServiceResponse here // QueryResponse QueryResponse::QueryResponse (int size) : size (size) {} Estd::string QueryResponse::getResponse () { return “{‘size’: ” + std::to string (size) + “}”; Hint QueryResponse::getSize() { return size; // Add your code for QueryResponse here class ServiceResponse { public: ServiceResponse (int length); explicit ServiceResponse (QueryResponse queryResponse); int getLength(); // Add your code here private: int length; std::string getResponse () ; – }; class QueryResponse { public: QueryResponse (int size); int getSize(); // Add your code here private: int size; std::string getResponse (); -}; Show transcribed image text Part 1 – Conversion Constructors Write Conversion Constructors for both QueryResponse and ServiceResponse in Response.cpp . Verify the following things in main class – 1. Create an object of QueryResponse and use the conversion constructor to create an object ServiceResponse from it. 2. Create an object of ServiceResponse and use the conversion constructor to create an object QueryResponse from it. Part 2 – Conversion Operators We can also use Conversion Operators instead of Conversion Constructors to achieve the same goal. Write Conversion Operators for both QueryResponse and ServiceResponse in Response.cpp . Verify the following things in main class – 1. Create an object of QueryResponse and use the conversion operator to create an object ServiceResponse from it. 2. Create an object of ServiceResponse and use the conversion operator to create an object QueryResponse from it. Part 3 – Friend Functions and Classes In order to get the ResponsePrinter class working, ResponsePrinter needs access to the private method getResponse of both QueryResponse & ServiceResponse classes. 1. Make ResponsePrinter a friend of QueryResponse to get the printQueryResponse method working. 2. Use the concept of Friend Function to get the printserviceResponse working. 3. Verify that you are able to print both in your main class.
int main(int argc, const char *argv[]) { // Part: 1 QueryResponse queryResponse (5); ServiceResponse serviceResponse (9); QueryResponse convertedQueryResponse; ServiceResponse convertedServiceResponse; // Add Your Code here std::cout
Expert Answer
Answer to Part 1 – Conversion Constructors Write Conversion Constructors for both QueryResponse and ServiceResponse in Response.cp…
OR