I can't seem to get the syntax for this function right, I am getting an error related to the function setNewContact. This file includes the function definitions for one of the classes in my program. Any idea where this error comes from?
Code:
#include "Person.h"
#include <iostream>
using namespace std;
/*This file contains the function definitions for class Person*/
Person::Person()
{
nextEmptySpot=0;
}
//This function prompts the user to input the contact’s first name, last name, address, zip code, phone number, email, and notes
//The user input gets placed in the contactList array
void Person::enterNewContact()
{
cout << "\n\tCreate a new contact selected.\n" << endl << "\tPress <Enter> after each input. " << endl
<< "\nPlease input the First Name: ";
getline(cin,firstName);
cout << "Please enter the Last Name: ";
getline(cin,lastName);
if (lastName=="")
{
cout<<"Last Name is a required field. Please try again.";
}
else {
cout << "\nPlease enter the Street Address, City,\nState, and Country separated by commas: ";
getline(cin,address);
cout << "\nPlease input the ZIP code: ";
getline(cin,zip);
cout << "Please input the Telephone Number: ";
getline(cin,phone);
cout << "Please input the email address: ";
getline(cin,email);
cout << "Please input any other information: ";
getline(cin,notes);
}
}
//puts the new person object into the array
void Person::setNewContact()
{
contactList[nextEmptySpot++]={firstName; lastName; address; phone; email; notes;}
// function returns two errors
}
These are the two compiler errors. I likely have the syntax for this function wrong.
Code:
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
I am trying to store the information inputted by the user in the function enterNewContact into one element of the array contactList.
I appreciate your help.