Question: Can someone help me fix these errors in the C++ code? I am getting a jump to case label [-fpermissive] when the switch statements begin,
Can someone help me fix these errors in the C++ code?
I am getting a jump to case label [-fpermissive] when the switch statements begin, a crosses initialization of 'Person person' error,cannot convert 'std::vector
#include
#include
#include
using namespace std; #include "Person.h"
int menu(); int find(vector
int main() { // Container for holding all Person objects. vector
int menu() { int choice; //add a person to the text file where names/addresses/etc. are stored cout << "1. Add Person" << endl; //search the text file for a name and it will return all of the person's info cout << "2. Search Directory" << endl; //removes a person's entry from the text file along with all of their personal data cout << "3. Remove Person" << endl; //exits from the program cout << "4. Exit" << endl; cout<<" Enter your choice: "; cin>>choice; return choice; }
// Finds a person and returns it index. int find(vector
void writeToFile(ofstream& out, vector
#ifndef PERSON_H_ #define PERSON_H_
#include
struct PersonDetails { string name, phone, address, email, website; };
class Person { private: string _name; string _phone; string _address; string _email; string _website; public: Person(); Person(PersonDetails p1); virtual ~Person();
string get_name();
friend ostream & operator << (ostream &, Person &); };
#endif /* PERSON_H_ */
Person.cpp
#include "Person.h" #include
Person::Person() { // Init all _name = ""; _phone = ""; _address = ""; _email = ""; _website = ""; }
Person::Person(PersonDetails pd1) { _name = pd1.name; _phone = pd1.phone; _address = pd1.address; _email = pd1.email; _website = pd1.website; }
Person::~Person() {}
string Person::get_name() { return this->_name; }
ostream & operator << (ostream &os, Person &p1) { os << p1._name; return os; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
