Hello, I looked around and saw similar problems, but None of the answers seemed to help my situation. Im almost done with my HW Just have come across this minor bump.
The error is in the title, and is happening in my addressEntry header, or cpp. not sure: : error C2512: 'addressEntry' : no appropriate default constructor available
its confusing me because I cant find any reason it won't compile. any help would be appreciated.
#include <iostream>
#include <cctype>
#include <string>
#include <fstream>
using namespace std;
#include "name.h"
#include "address.h"
#include "addressEntry.h"
#include "addrbook.h"
void askUser(char & option);
void printMenu();
bool isValid(char option);
void optionOne();
void optionThree();
int main()
{
Name myName("Andrew", "Russell");
Name operatorName;
Address operatorAddress;
addressEntry operatoraddressEntry;
char option = 0;
char newOption = 0;
char another = 'y';
addrBook stuff;
double itemToAdd;
int counterToRemove = 0;
string itemRemove;
string newName,newLast,newAddress, newCity, newState, newZip, newPhone, newEmail, newBirthday, newPict;
ofstream myfile ("address.dat");
while(option != '5')
{
myName.printName();
askUser(option);
if(isValid(option))
cout << "You selected: " << option << endl;
else
cout << "Invalid Entry selected\n";
switch(option)
{
case '1':
cout << "Enter your First Name: ";
cin >> newName;
operatorName.setFirstName(newName);
cout << "Enter your Last Name: ";
cin >> newLast;
operatorName.setLastName(newLast);
cout << "\nPlease Enter your Street Address: ";
if(cin.peek() == '\n')
cin.ignore();
getline(cin, newAddress);
operatorAddress.setStreet(newAddress);
cout << "\nPlease Enter your City: ";
cin >> newCity;
operatorAddress.setCity(newCity);
cout << "\nPlease Enter your State: ";
cin >> newState;
operatorAddress.setState(newState);
cout << "\nPlease Enter your Zip Code: ";
cin >> newZip;
operatorAddress.setZip(newZip);
cout << "\nPlease Enter your Phone Number: ";
if(cin.peek() == '\n')
cin.ignore();
getline(cin, newPhone);
operatoraddressEntry.setPhoneNumber(newPhone);
cout << "\nPlease Entr your Birthday: ";
if(cin.peek() == '\n')
cin.ignore();
getline(cin, newBirthday);
operatoraddressEntry.setBirth(newBirthday);
cout << "\nPlease Enter your Email Address: ";
cin >> newEmail;
operatoraddressEntry.setEmail(newEmail);
cout << "\nPlease Enter your Pict File: ";
cin >> newPict;
operatoraddressEntry.setPict(newPict);
stuff.add(operatorName.getFullName() + operatorAddress.getFullAddress() + operatoraddressEntry.getFullInfo());
break;
case '2':
stuff.printUsed();
break;
case '3':
stuff.print();
break;
case '4':
// prompt for counting
// number to remove
stuff.remove(counterToRemove-1);
break;
case '5':
cout << "Goodbye!\n";
break;
default:
cout << "Error";
}
}
myfile.close();
return 0;
}
void askUser(char & option)
{
printMenu();
cin >> option;
}
void printMenu()
{
cout << "1. Add a new addressEntry to the AddressBook\n";
cout << "2. Find out how many items in the AddressBook\n";
cout << "3. Print out all the items in the AddressBook\n";
cout << "4. Delete an item from the AddressBook\n";
cout << "5. Exit the Program\n\n";
}
bool isValid(char option)
{
if(option > 53 || option < 49)
return false;
else
return(true);
}
void optionOne()
{
string newName,newLast,newAddress, newCity, newState, newZip, newPhone, newEmail, newBirthday;
Name operatorName;
Address operatorAddress;
addrBook stuff;
cout << "Enter your First Name: ";
cin >> newName;
operatorName.setFirstName(newName);
cout << "Enter your Last Name: ";
cin >> newLast;
operatorName.setLastName(newLast);
cout << "\nPlease Enter your Street Address: ";
if(cin.peek() == '\n')
cin.ignore();
getline(cin, newAddress);
operatorAddress.setStreet(newAddress);
cout << "\nPlease Enter your City: ";
cin >> newCity;
operatorAddress.setCity(newCity);
cout << "\nPlease Enter your State: ";
cin >> newState;
operatorAddress.setState(newState);
cout << "\nPlease Enter your Zip Code: ";
cin >> newZip;
operatorAddress.setZip(newZip);
// End of, Input
cout << "\n****This is the Information that you Have provided****" << endl << endl;
cout << "Name & Address:\n" << newName << " " << newLast << endl;
cout << newAddress << "\n" << newCity << ", " << newState << " " << newZip << endl;
cout << "Phone Number: " << newPhone << endl;
cout << "Birth Date: " << newBirthday << endl;
cout << "Email: " << newEmail << endl;
}
void optionThree()
{
string line;
ifstream myfile ("address.dat");
cout << "\n\n";
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
}
Here is the Header and The cpp that are causing the problem.
#ifndef ADDRESSENTRY_H
#define ADDRESSENTRY_H
#include <string>
class addressEntry
{
public:
addressEntry::addressEntry(string phoneIn, string birthIn, string emailIn, string pictIn);
string addressEntry::getPhoneNumber() const;
string addressEntry::getBirthday() const;
string addressEntry::getEmail() const;
string addressEntry::getPict() const;
string addressEntry::getFullInfo() const;
void addressEntry::setPhoneNumber(string phoneIn);
void addressEntry::setBirth(string birthIn);
void addressEntry::setEmail(string emailIn);
void addressEntry::setPict(string pictIn);
private:
string phone;
string birth;
string email;
string pict;
};
#endif
#include <iostream>
#include <string>
using namespace std;
#include "addressEntry.h"
addressEntry::addressEntry(string phoneIn, string birthIn, string emailIn, string pictIn)
{
phone = phoneIn;
birth = birthIn;
email = emailIn;
pict = pictIn;
}
string addressEntry::getPhoneNumber() const
{
return(phone);
}
string addressEntry::getBirthday() const
{
return(birth);
}
string addressEntry::getEmail() const
{
return(email);
}
string addressEntry::getPict() const
{
return(pict);
}
string addressEntry::getFullInfo() const
{
return("Phone Number:" + phone + "\n" + email + "\n" + birth + "\n" + pict + "\n");
}
void addressEntry::setPhoneNumber(string phoneIn)
{
phone = phoneIn;
}
void addressEntry::setBirth(string birthIn)
{
birth = birthIn;
}
void addressEntry::setEmail(string emailIn)
{
email = emailIn;
}
void addressEntry::setPict(string pictIn)
{
pict = pictIn;
}