Question: This is a C++ question and development environment is Visual Studio 2015. The code below defines a class CAT that contains a private variable cName[80].

This is a C++ question and development environment is Visual Studio 2015.

The code below defines a class CAT that contains a private variable cName[80]. A function nameSwap() that swaps the name of two cats by using pointers is also defined. Design the nameSwap() function and the main() that will fulfill the following criteria. 1. Create and initialize cName[ ] of two CAT objects in the heap pointed by pA and pB as "Taby" and "Felix" respectively. 2. Show the initial name of the two cats created 3. Swap the name (i.e. string in cName[ ]) of the two cats using the pointer approach (Only swap the name, NOT the object) 4. Show the name again. #define _CRT_SECURE_NO_WARNINGS 1 #include #include using namespace std; class CAT {public: CAT(char * firstname) {strncpy(cName,firstname,79);} ~CAT() {;} char * getName() {return cName;} void setName(char *nameinput) {strncpy(cName,nameinput,79);} private: char cName[80]; }; void nameSwap(CAT *CatA, CAT *CatB);

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!