Question
1. Please write the following in C++ also please show all output code and comment on code. Write CppUnitLite tests to verify correct behavior for
1. Please write the following in C++ also please show all output code and comment on code.
Write CppUnitLite tests to verify correct behavior for all the exercises. The modifications are aimed at making the exercises more conducive to unit tests.
Write a function that swaps (exchanges the values of two integers). Use int* as the argument type. Write a second swap function using a reference (i.e., int&) as the argument type.
Define a table of the names of months of the year and the number of days in each month. Write out that table to a stringstream. Do this twice; once using an array of char for the names and an array for the number of days and a second time using an array of structures, with each structure holding the name of a month and the number of days in it.
Write a function cat() that takes two C-style strings (i.e., char*) arguments and returns a C-style string that is the concatenation of the arguments. Use new to find store for the result. Write a second function cat that takes two const std::string& arguments and returns a std::string that is a concatenation of the arguments. The std::string version does not require new. Which is the better approach? Explain your rationale for which is the better approach?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started