practice Exam1 - struct Thingcfw string draw int area void...

Info icon This preview shows pages 1–4. Sign up to view the full content.

struct Thing{ string draw; int area; }; void fill(ifstream& file, vector<Thing>& things){ string d; int a; while(file>>d>>a){ Thing th; th.draw=d; th.area=a; things.push_back(th); } } int totalArea(const vector<Thing>& things){ int total=0; for (size_t i=0; i<things.size(); i++){ total+=things[i].area; } return total; }
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

12. class Face{ string name; Face* boss; vector<Face*> vecF; public: Face(string aname): name(aname), boss(NULL){} bool blendWith(Face& emp){ if (&emp==this){ return false; } else if(emp.boss==this){ return false; } else if(boss==&emp){ return false; } else{ if (boss!=NULL){ for (size_t i=0; i<boss->vecF.size();i++){ if(boss->vecF[i]==this){ boss->vecF[i]=boss->vecF[boss->vecF.size()-1]; boss->vecF.pop_back(); break; } } } emp.vecF.push_back(this); boss=&emp; return true; } } void display(){ cout<<”Name: “<<name<<”; Leader: “; if(boss=NULL){ cout<<”none; “; } else{ cout<<boss->name; } cout<<”; Faces: “;
Image of page 2
if(vecF.size()==0){ cout<<”none.”; } else{ for (size_t i=0; i< vecF.size();i++){ cout<<vecF[i]->name<<” “; } } cout<<”.”<<endl; } }; class Face{ string name; //everyone has a name Face * boss; //allows employees to point to a boss vector < Face
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 4
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '08
  • Sterling
  • Pointer, boss, MOE

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern