QuestionQuestion

Check the file: Questions.pdf

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

Drivers.cpp:

#include "Hero.h"
#include <iostream>
#include <string>
#include <vector>
#include <fstream>

//Free the alocated memory for heroes
void deleteHeroes(std::vector<Hero *> list) {
Hero *hero;
for (int i = 0; i < list.size(); i++) {
hero = list[i];
hero->deletePowers(); //delete powers attached to hero
delete hero;
}
list.empty();
}

//read in file and add each hero as vector input
void loadHeroes(std::string filename, std::vector<Hero *> &list) {
Hero *hero;
std::ifstream infile(filename);
if (infile.is_open()) {
std::string newLine;
deleteHeroes(list); //empty the list for case of reloading
while (!infile.eof()) {
std::getline(infile, newLine);
hero = new Hero(newLine);
list.push_back(hero);
}
std::cout << list.size() << " heroes loaded." << std::endl;
}
//file does not exist
else {
std::cout << "File not found." << std::endl;
}
}

//iterate through heroes list and print each of their powers
void printRoster(std::vector<Hero *> list) {
std::cout << "The following " << list.size() << " heroes are loaded..." << std::endl;
for (int i = 0; i < list.size(); i++) {
std::cout << "--------------------" << std::endl;
list[i]->printPower();
}
}...
$35.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats