Struct Villian and copyVillian function
Not what you're looking for?
Suppose I have declared the following struct:
struct Villian {
int wit;
int stealth;
int slainCount;
int slainCap;
string* victimsSlain;
};
Also assume the existence of a function copyVillian (as declared below) that takes two Villian params, one called orig and the other called copycat, and makes copycat a deep copy of orig.
void copyVillian (struct Villian * orig, struct Villian * copycat);
Please explain and tutor for the below.
1. Show how you would use the above copyVillian function to create a copy of sharpay called sharpaysMoreEvilTwin.
2. Now create a new Villian value called badGuy that you declare dynamically. Then, set badGuy's values as follows:
wit: 31 stealth: 25 slainCap: 4
slainCount: 2
victimsSlain[0]: Garko
victimsSlain[1]: Sparko
Purchase this Solution
Solution Summary
Detailed comments are provided to help the reader in understanding the code.
Solution Preview
1.
// Declare the structure variable sharpaysMoreEvilTwin first.
struct Villian sharpaysMoreEvilTwin;
// Assuming that the structure variable sharpay is already declared and
// properly initialised, here is how we can ...
Purchase this Solution
Free BrainMass Quizzes
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.
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.
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.
C++ Operators
This quiz tests a student's knowledge about C++ operators.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.