Purchase Solution

Struct Villian

Not what you're looking for?

Ask Custom Question

Please add comments using //.

Suppose I have declared the following struct:

struct Villian {
int wit;
int stealth;
int slainCount;
int slainCap;
string* victimsSlain;
};

1. Declare a new Villian called sharpay who has a wit of 24, a stealth of 16, and who has currently claimed three victims: Chad, Troy, and Gabriella. Give sharpay an initial capacity to vanquish 10 victims.

2. Write a function called copyVillian that takes two Villian parameters, one called orig and the other called copycat, and makes copycat a deep copy of orig. Hint: a "deep copy" is one that would allow copy to exist completely separately from orig. In other words, they will not share any memory locations.

Purchase this Solution

Solution Summary

As nothing specifically is mentioned about the sharpay variable declaration and the type of copyVillian function parameters, this solution declares sharpay as an initialized variable and copyVillian function parameters are considered as pointer types. Detailed comments are provided to help the reader in understanding the code.

Solution Preview

As nothing specifically is mentioned about the sharpay variable declaration and the type of copyVillian function parameters, this solution declares sharpay as an initialized variable and copyVillian function parameters are considered as pointer types.

struct Villian {
int wit;
int stealth;
int slainCount;
int slainCap;
string* victimsSlain;
};

1.

string sharpayVictims[] = {"Chad", "Troy", "Gabriella"};

// Following statement declares a new Villian called sharpay who has a wit of
// 24, a stealth of 16, ...

Purchase this Solution


Free BrainMass Quizzes
C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.