Question: I receive these errors for the play.cpp file i ' m working on . Here's my file: / / play . cpp #include #include #include

I receive these errors for the play.cpp file i'm working on. Here's my file:
//play.cpp
#include
#include
#include
using std::string;
using std::vector;
using std::map;
using std::cout;
using std::endl;
#include "play.h"
#include "playTools.h"
Speech::Speech(string speaker, vector lines){
//initialize theSpeaker and theLines
//to speaker and lines
this->theSpeaker = speaker;
this->theLines = lines;
}
string Speech::getSpeaker(){
//return theSpeaker
return theSpeaker;
}
vector Speech::getLines(){
//return theLines
return theLines;
}
void Speech::print(){
//print the speech using cout
//this is primarily meant for debugging
//so print what is useful to you
//I'd recommend, theSpeaker and each line of the speech
//at the very least
cout "Speaker: " theSpeaker endl;
for (auto& line : theLines){
cout line endl;
}
}
Scene::Scene(int actNum, int sceneNum, string loc){
//initialize actNumber, sceneNumber, and location to the
//appropriate values
this->actNumber = actNum;
this->sceneNumber = sceneNum;
this->location = loc;
}
string Scene::toString(){
//return a string of this form:
//Act: 2 Scene: 2 Location: Capulet's orchard.
return "Act: "+ std::to_string(actNumber)+" Scene: "+ std::to_string(sceneNumber)+" Location: "+ location +".";
}
Play::Play(string title){
//this will take in the title,set theTitle, and use it to generate
//theScenes (see playTools.cpp), theSpeeches (see playTools.cpp),
//and numLines (this one you'll have to do yourself)
//numLines is the total number of lines in the play
//this can be found by counting all of the lines in each
//speech in theSpeeches
this->theTitle = title;
theSpeeches = makeListOfSpeeches(title);
theScenes = makeListOfScenes(title);
numLines =0;
for (auto& speech : theSpeeches){
numLines += speech.getLines().size();
}
}
void Play::printAllScenes(){
//this will loop through all of the scenes in theScenes,
//call its toString() method, and cout each scene on a
//separate line
for (auto& scene : theScenes){
cout scene.toString() endl;
}
}
vector Play::allParts(){
//this loops through theSpeeches and saves each speaker
//but only saves them once.
//Hints:
//Build up a vector of roles through repeated push_back.
//This will involve looking at the speaker associated with every speech
//in the play. If the speaker is not already in the current version of
//of the vector, then push_back. Otherwise, there is nothing to do because
//the speaker is in the vector already.
//Note: the list returned by allParts should have no repeated entries
//and the order does not matter.
vector roles;
for (auto& speech : theSpeeches){
string speaker = speech.getSpeaker();
if (std::find(roles.begin(), roles.end(), speaker)== roles.end()){
roles.push_back(speaker);
}
}
return roles;
}
map Play::speakersAndLineCnt(){
//this loops through theSpeeches and counts how many lines
//each speaker has, which it saves as a speaker,numLines pair
map speakerCount;
for (auto& speech : theSpeeches){
speakerCount[speech.getSpeaker()]+= speech.getLines().size();
}
return speakerCount;
}
int Play::wordFreq(string word){
//this loops through theSpeeches and counts how many times
//the given word appears in the play
int c =0;
for (auto& speech : theSpeeches){
for (const auto& line : speech.getLines()){
c += std::count(line.begin(), line.end(), word);
}
}
return c;
}
//end of play.cpp
I receive these errors for the play.cpp file i '

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 Programming Questions!