Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions